Loading
Feature Disruption - Service Cloud VoiceRead More
Feature degradation | Gmail Email delivery failureRead More
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
          Add a Counter to the Display List

          Add a Counter to the Display List

          Add a counter to show the number of display records that are visible on the card and the total number of display records.

          Required Editions

          User Permissions Needed
          To customize CG Cloud offline mobile app: Customizer, Developer

          Define a new function to determines the counter information.

          1. To create a business logic, run the command in your workspace: sf modeler workspace add
          2. Select businesslogic as the resource type. Provide the required inputs to add the businesslogic contract as per the instructions in the command.
          3. Enter a name for the businesslogic function and add the function to LoMyDisplays. For example, GetInfoForDisplayCard.
            ? Select the resource you want to add. businesslogic
            ? Specify a name for the businesslogic: GetInfoForDisplayCard
            ? Select the module to which businesslogic 'GetInfoForDisplayCard' should be added. MyDisplay
            ? Select a suitable option for businesslogic 'GetInfoForDisplayCard'. method
            ? Select the reference object to which you want to add the businesslogic method. LoMyDisplays
            ? Do you really want to create the businesslogic 'GetInfoForDisplayCard'? Yes

            The add command creates a new function and registers it in the list object:

            <ListObject name="LoMyDisplays" generateLoadMethod="true" schemaVersion="1.1">
              <DataSource name="DsLoMyDisplays"/>
              <Item objectClass="LiMyDisplays"/>
              <Methods>
                <Method name="beforeSaveAsync"/>
                <Method name="afterSaveAsync"/>
                <Method name="afterLoadAsync"/>
                <Method name="beforeLoadAsync"/>
                <Method name="afterDoValidateAsync"/>
                <Method name="beforeDoValidateAsync"/>
              <Method name="myGetInfoForDisplayCard"/></Methods>
            </ListObject>
            These businesslogic method files are automatically created by the framework.

            The myGetInfoForDisplayCard function determines the count of the list items to show in the card depending on the form factor and the overall count. The myGetInfoForDisplayCard function returns a string that you can use to bind to the card.

              * @function myGetInfoForDisplayCard
              * @this LoMyDisplays
              * @kind listobject
              * gamespace CUSTOM
              * @returns info
              */
            function myGetInfoForDisplayCard(){
                    var me = this;
            //////////////////////////////////////////////////////////////
            //        Add your customizing javaScript code below..      //
            //////////////////////////////////////////////////////////////
                 // determine the max number of list items to show in card (depending on form factor)
                 var limitDueToFormFactor = Utils.isPhone() ? 3 : 5;
            
                 // number of loaded list items
                 var numberOfListItems = me.getCount();
                 // info text to show in card
                 var info;
            
                 // if you have less then 3/5 items show less number otherwise show 3/5
                 // e.g. tablet mode and there are loaded 12 records --> 5 / 12
                 // e.g. tablet mode and there are loaded 2 records --> 2 / 2
                 var shownItems = numberOfListItems > limitDueToFormFactor ? limitDueToFormFactor : numberOfListItems;
            
                 if (numberOfListItems > 0) {
                    info = shownItems + " / " + numberOfListItems;
                 }
                 else {
                     info = " "
                 }
            The method definition to configure the counter.
          4. Integrate the function call into the process flow. Create a process variable to store the counter text.
            <!-- Card: Display -->
            <Declaration name="CardDisplay_DataLoaded" type="DomBool"/>  
            <Declaration name="CardDisplay_SubComponentName" type="String"/>
            <Declaration name="CardDisplay_DisplayList" type="LoMyDisplays"/>
            <Declaration name="CardDisplay_InformationText" type="String" />
          5. Add an action on the loadData action that calls the new function. Use the LOGIC action type and ensure that the new function is defined on the LoMyDisplays list (CardDisplay_DisplayList).
            <!-- Card: Display START-->
                  <Action name="CardDisplay_loadData" actionType="LOAD" type="LoMyDisplays"
                        <Return name="ProcessContext::CardDisplay_DisplayList" />
                        <TransitionTo action="CardDisplay_loadInformationText"/>
                  </Action>
                  <Action name="CardDisplay_loadInformationText" actionType="LOGIC" call="ProcessContext::CardDisplay_DisplayList.myGetInfoForDisplayCard">
                        <Parameters>
                             <Input name="loItems" value="ProcessContext::CardDisplay_DisplayList"/>
                             <Input name="type" value="Display" type="Literal" />
                        </Parameters>
                        <Return name="ProcessContext: :CardDisplay_InformationText" />
                        <TransitionTo action="CardDisplay_setSubcomponentName"/>
          6. To point to the new process variable filled by the newly created function, modify the card binding in the UI contract.
             <!-- Title and counter -->
                <Resource target="Title" type="Label" id="DisplayCardTitle" defaultLabel="Displays" />
                <Binding target="Information" type="Text" binding="ProcessContext::CardDisplay_InformationText" bindingMode="ONE_WAY" />
          7. Build the contracts by running the command sf modeler workspace build or the alias command sf mdl ws build in your workspace.
          8. To test the changes, restart the simulator app.
           
          Loading
          Salesforce Help | Article