Loading
Visual Studio Code Based Modeler for Consumer Goods Cloud
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Integrate Customer Lookup on Display Card

          Integrate Customer Lookup on Display Card

          To show the current account in Displays, configure the BoMyDisplay business object and DsBoMyDisplay datasource contracts in Visual Studio Code based Modeler. To create a wizard to select a different account, add an action to the MyDisplay_DisplayDetailsProcess process contract. Lastly, test the configuration in the simulator app.

          Required Editions

          Available in: Lightning Experience

          Available in: Enterprise and Unlimited Editions where Consumer Goods Cloud is enabled

          User Permissions Needed
          To configure customer look-up to a display record

          Developer, Customizer

          1. In Visual Studio Code based Modeler, adapt business object and datasource to load the customer ID from the database.
            1. Add this snippet to the Attributes node in DsBoMyDisplay_sf.datasource.xml contract.

              This snippet defines an attribute named customer that maps to the Account__c column in the Display__c table.

              <Attribute name="customer" table="Display__c" column="Account__c" />
            2. Add this snippet to the SimpleProperties node in BoMyDisplay.businessobject.xml contract.

              This code snippet defines a simple property named customer with the type DomPKey and links it to the customer data source property.

              <SimpleProperty name="customer" type="DomPKey" dataSourceProperty="customer"/>
            3. Add this snippet to the ObjectLookups node in BoMyDisplay.businessobject.xml contract.

              This code snippet defines the luCustomer object lookup that references the LuCustomer object class, links it to the customer data source property and uses the pKey property for the lookup.

              <ObjectLookup name="luCustomer" objectClass="LuCustomer" dataSourceProperty="customer" lookupProperty="pKey" />
          2. Create a lookup control in the Detail area of the Display module.
            1. In MyDisplay_DisplayDetailsUI.userinterface.xml, add a lookup control in the Info group.

              This code snippet defines the Customer lookup with bindings for a label and a two-way value binding to the current display's customer name. It also defines an event for the customer lookup.

              <Lookup name="Customer">
                 <Bindings>
                    <Resource target="Label" type="Label" id="CustomerId" defaultLabel="Customer" />
                    <Binding target="Value" binding="ProcessContext::CurrentDisplay.luCustomer.name" bindingMode="TWO_WAY" />
                 </Bindings>
                 <Events>
                    <LookupEvent event="CustomerLookup" />
                 </Events>
              </Lookup>

              This snippet shows the position of the Lookup code block in the Area section.

              <Area areaName="detailArea" areaPattern="GroupedElementsArea">
                 <GroupElement name="Info">
                    <Bindings>
                       <Resource target="Title" type="Label" id="DisplayDetailInfoGroup" defaultLabel="Info" />
                    </Bindings>
                    <InputArea name="Name">
                       <Bindings>
                          <Resource target="Label" type="Label" id="DisplayName" defaultLabel="Name" />
                          <Binding target="Value" binding="ProcessContext::CurrentDisplay-name" bindingMode="TWO_WAY" />
                    </Bindings>
                    </InputArea>
                    <InputAreaMultiLine name="Description" no0fRows="3">
                       <Bindings>
                          <Resource target="Label" type="Label" id="DisplayDescription" defaultLabel="Description" />
                          <Binding target="Value" binding="ProcessContext: :CurrentDisplay.description" bindingMode="TWO_WAY" />
                       </Bindings>
                    </InputAreaMultiLine>
                    <Lookup name="Customer">
                       <Bindings>
                          <Resource target="Label" type="Label" id="CustomerId" defaultLabel="Customer" />
                          <Binding target="Value" binding="ProcessContext:: CurrentDisplay. luCustomer.name" bindingMode="TWO_WAY" />
                       </Bindings>
                       <Events>
                          <LookupEvent event="CustomerLookup". />
                       </Events>
                    </Lookup>
            2. Save all the contracts.
          3. To change the account for an existing display, call an existing wizard to select a customer.
            1. To trigger the lookup wizard of the customer module in Displays, in MyDisplay_DisplayDetailsProcess.processflow.xml, configure the event handler for the UI action. Add this snippet to the View Action Events node.

              This code snippet defines the CustomerLookup event that triggers the action OpenCustomerNameLookup.

              <Event name="CustomerLookup" action="OpenCustomerNameLookup"/>
            2. To create an action to call a lookup process to retrieve an account ID, add this Action code to the Actions node.

              This code snippet defines the OpenCustomerNameLookup action that triggers the Customer::LookupProcess process, returns a customer primary key value to the current display's customer context, and transitions to the LoadCustomerLookup action.

              <Action actionType="PROCESS" name="OpenCustomerNameLookup" process="Customer::LookupProcess">
                 <ReturnValues>
                    <Return name="ProcessContext::CurrentDisplay.customer" value="customerPKey" />
                 </ReturnValues>
                 <TransitionTo action="LoadCustomerLookup" />
              </Action>
            3. To load the lookup object for a given account ID, create an action. Add this Action snippet to the Actions node.

              This code snippet defines the LoadCustomerLookup load action that loads a customer lookup of type LuCustomer using the customer primary key from the current display's context and returns the loaded customer lookup to the current display's context.

              <Action actionType="LOAD" name="LoadCustomerLookup" type="LuCustomer">
                 <Parameters>
                    <Input name="pKey" value="ProcessContext::CurrentDisplay.customer" />
                 </Parameters>
                 <Return name="ProcessContext::CurrentDisplay.luCustomer" />
              </Action>
            4. Save all the contracts.
          4. To verify the changes, test the app with the customer lookup.
            1. To build your contracts, run sf mdl build.
            2. To test the changes, restart the simulator app.

              In the simulator app, open a display record. In the display details page, tap the arrow in the Customer field. The app launches the customer list, as shown in this image.

              This image shows the customer look-up list for a display record.
           
          Loading
          Salesforce Help | Article