Published: June 2, 2017

Salesforce CRM Salesforce cloud-based customer relationship management platform is extensively used by enterprises for sales automation, customer service, marketing, commerce, and much more. It was recently named as a #1 CRM provider by International Data Corporation (IDC). Over the years, Salesforce has gained immense popularity among B2B customers and IT practitioners due to its flexibility, speed and ease of maintenance. However, Salesforce implementation and integration can be a challenge even for experienced IT consulting companies. Bridging the gap between business and technical requirements is crucial for a successful implementation and integration.

Salesforce Implementation and Customization

Salesforce developers come across quite a few technical challenges during implementation and customization. This blog provides certain best practices for IT practitioners seeking to implement and customize the Salesforce platform. Moreover, it specifically addresses a key concern relating to getting and updating selected records from a related list in Salesforce. 

This post is primarily for developers having basic knowledge of objects, layouts, custom links & buttons, apex, and visualforce pages. It is important to note that Salesforce has two different user interfaces, Lightning Experience and Salesforce Classic; it is easy to switch between the two interfaces. Here in this case, we have used the Salesforce Classic interface.

Getting and Updating Selected Records

To begin with, let us consider an example of ‘quote’ and ‘quote line item objects’ with a master-detail relationship. The ‘quote line item records’ are displayed as a related list on quote record. Further, the ‘quote line items records’ contain a field titled ‘comments’. In order to ‘add/modify’ comments for a selected ‘quote line Items record’ developers have to add a custom button and custom logic. Here are a few steps explaining the process of creating custom components in the Salesforce platform.

Creating Custom Components

  • Create an apex class ‘AddOrUpdateComments’ using the below code:
[java]public with sharing class AddOrUpdateComments {
public AddOrUpdateComments(ApexPages.StandardSetController controller) {
}
}[/java]

  • Create a visual-force page ‘addOrUpdateComments’ and add the following code:
[java]<apex:page standardController="QuoteLineItem"  recordSetVar="QuoteLineItems" extensions="AddOrUpdateComments">
<apex:form >
<apex:pageBlock title="Quote Line Item Comments">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!selected}" var="quoteLine">
<apex:column headerValue="Service Name">
<apex:outputLabel value="{!quoteLine.Product2.Name}" style="width:50%"/>
</apex:column>
<apex:column headerValue="Comments">
<apex:inputField value="{!quoteLine.Comments__c}" style="width:100%"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
[/java]
  • Now create a new custom button titled ‘Add/Modify Comments’.

Adding List Button Screen

  • Add custom button to the layout.

Adding Custom Button

After the above steps are completed, let us proceed to the user experience screens. 

  • Select quote line items and click on ‘Add/Modify Comments’ button.

Adding comments to the Quote Line Items screen

  • Enter comments and click on the ‘Save’ button.

Enter and save comments

  • The comments entered are added to the ‘Quote lines’ as depicted below.

Image depicting Quote lines

Summing-up

This blog helps developers to get acquainted with the process of getting and updating selected records from a related list. Please feel free to write your comments or ask questions (if any) in the comments section below. 

Salesforce Consulting Services

Evoke Technologies offers end-to-end Salesforce consulting services to global enterprises. We have been assisting enterprise in planning, designing, and implementing Salesforce based CRM solutions. With our business-focused approach, we are highly successful in modernizing and transforming our clients’ CRM systems utilizing various components of the Salesforce product platform. 

Further, with our domain knowledge and technical expertise on cloud-driven technologies, we are in a position to easily understand and swiftly address our client’s business concerns. To learn more about our Salesforce consulting services, contact us via our website or call us at +1 (937) 202-4161 (select Option 2 for Sales).

Author

Dhananjaya Rao Budireddi was a Technical Lead at Evoke Technologies. With his extensive knowledge and experience on Oracle CPQ Cloud, Salesforce and Java/J2EE technologies, he likes resolving customers technical challenges. Dhananjaya is passionate about technology and keen to learn and explore emerging cloud-based technologies.
Please follow and share

Leave a comment