Loading
Salesforce now sends email only from verified domains. Read 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
          Configure the Number of Visible Records in a List

          Configure the Number of Visible Records in a List

          Limit the number of visible list items to show and sort the items in alphabetical order on the card.

          Required Editions

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

          To optimize app performance and usability, limit the number of visible list items in the card to 5 in tablet mode and 3 in phone mode in a card. The framework supports a maximum of 20 list items to show on a card in the CG Cloud offline mobile app.

          1. To sort the display list in alphabetical order and show the first five display records, add an order criteria to the DsLoMyDisplays data source contract.
            <DataSource name="DsLoMyDisplays" backendSystem="sf" businessObjectClass="LoMyDisplays" external="false" editableEntity="Display__c" schemaVersion="2.0">
                  <Attributes>
                        <Attribute name="id" table="Display__c" column="Id" />
                        <Attribute name="name" table="Display__c" column="Name" />
                        <Attribute name="description" table="Display__c" column="Description_c" />
                        <Attribute name="competitorDisplay" table="Display__c" column="Competitor_Display_c" />
                  </Attributes>
                   <Entities>
                       <Entity name="Display__c" alias="" idAttribute="Id" />
                   </Entities>
                   <QueryCondition/>
                   <OrderCriteria>
                        <OrderCriterion entity="Display__c" attribute="Name" direction="ASC" />
                   </OrderCriteria>
                   <Parameters/>
              </DataSource>
          2. Create the ReduceNumberOfListItems business logic function in LoMyDisplays by using the sf modeler workspace add CLI command.
            ? Select the resource you want to add. businesslogic
            ? Specify a name for the businesslogic: ReduceNumberOfListItems
            ? Select the module to which businesslogic 'ReduceNumberOfListItems' should be added. MyDisplay
            ? Select a suitable option for businesslogic 'ReduceNumberOfListItems'. method
            ? Select the reference object to which you want to add the businesslogic method. LoMyDisplays
            ? Do you really want to create the businesslogic 'ReduceNumberOfListItems'? Yes
            Successfully created businesslogic 'LoMyDisplays.MyReduceNumberOfListItems'
          3. Use these functions to determine and show the number of display records.
            • Utils.isPhone() - Returns true in phone mode
            • <List>.getAllItems() - Returns an array with all list items
            • <List>.removeAllItems() - Removes all items from the list object
            • <List>.addItems(itemArray) - Adds the given item array to the list object
            * @function myReduceNumber0fListItems
              * @this LoMyDisplays
              * @kind listobject
              * @namespace CUSTOM
              */
             function myReduceNumber0fListItems(){
                   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;
            
                   // get all items as array
                   var displayItems = me.getAllItems();
            
                   // reduce items
                   displayItems.splice(limitDueToFormFactor);
            
                   //clear list
                   me. removeAllItems ();
            
                   // add reduced items
                   me.addItems (displayItems) ;
            Shows the logic defined for ReduceNumberOfListItems function.
          4. To call the ReduceNumberOfListItems function, modify the action flow in Application_CockpitProcess.processflow.xml.
               <!-- 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_reduceListItems"/>
                  </Action>
                  <Action name="CardDisplay_reduceListItems" actionType="LOGIC" call="ProcessContext::CardDisplay_DisplayList.myReduceNumberOfListItems">
                       <TransitionTo action="CardDisplay_setSubcomponentName" />
                  </Action>
          5. Build the contracts by running the command sf modeler workspace build or the alias command sf mdl ws build in your workspace.
          6. To test the changes, restart the simulator app.

          The simulation app shows the display records sorted alphabetically.

           
          Loading
          Salesforce Help | Article