Loading
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 Business Object to Load the Display Details

          Add a Business Object to Load the Display Details

          When you tap a list item on the parent list, for the master-detail handler to load the item detail, create a business object (CurrentDisplay).

          Required Editions

          Available in: Enterprise and Unlimited Editions where Consumer Goods Cloud is enabled
          User Permissions Needed
          To add and configure a business object Customizer, Developer

          You can configure the behavior of the master-detail handler to reload the list even if the list item is unselected. For example, when you modify the values of fields such as name and description, the app updates those values in the detail area. The app also automatically saves the updates you make to the business objects and runs the validations required to save the changes, regardless of whether a save action was initiated by the user.

          1. In your VS Code based Modeler workspace, create a business object by running this command - sf modeler workspace add.
            The framework creates the default functions required for a business object.
            ? Select the resource you want to add. businessobject
            ? Specify a name for the businessobject: Display
            ? Select the module to which businessobject 'Display' should be added. MyDisplay
            ? Do you really want to create the businessobject 'Display'? Yes
            Successfully created businessobject 'BoMyDisplay'. */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/BoMyDisplay.businessobject.xml */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/CreateAsync/BoMyDisplay.AfterCreateAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/CreateAsync/BoMyDisplay.BeforeCreateAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/DoValidateAsync/BoMyDisplay.AfterDoValidateAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/DoValidateAsync/BoMyDisplay.BeforeDoValidateAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/Initialize/BoMyDisplay.AfterInitialize.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/Initialize/BoMyDisplay.BeforeInitialize.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/LoadAsync/BoMyDisplay.AfterLoadAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/LoadAsync/BoMyDisplay.BeforeLoadAsync.bl.js */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/SaveAsync/BoMyDisplay.AfterSaveAsync.bl.js
            */Users/demoUser/modeler_demo/src/MyDisplay/BO/BoMyDisplay/Mv2/SaveAsync/BoMyDisplay.BeforeSaveAsync.bl.js
            * /Users/demoUser/modeler_demo/src/MyDisplay/DS/DsBoMyDisplay_sf.datasource.xml
          2. Define the simple properties of the business object.
            <SimpleProperties>
              <SimpleProperty name="pKey" type="DomPKey" dataSourceProperty="pKey" />
              <SimpleProperty name="name" type="DomText" dataSourceProperty="name" />
              <SimpleProperty name="description" type="DomLongDescription" dataSourceProperty="description" />
              <SimpleProperty name="competitorDisplay" type="DomBool" dataSourceProperty="competitorDisplay" />
            </SimpleProperties>
          3. To load display records from the database, define the DsBoMyDisplays data source.
            1. Configure the columns and corresponding mapping attribute names used in business object. simple properties.
            2. To read a single Display record by a given pKey or id, define a condition and a parameter.
            3. Specify a pKey parameter and use it in the query condition to select a specific record.
            <DataSource name="DsBoMyDisplays" backendSystem="sf" businessObjectClass="BoMyDisplay" external="false" editableEntity="Display__c" schemaVersion="2.0">
              <Attributes>
                <Attribute name="pKey" 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>
                <![CDATA[
                  Display__c.Id = #pKey#
                ]]>
              </QueryCondition>
              <OrderCriteria/>
              <Parameters>
                <Parameter name="pKey" type="TEXT" />
              </Parameters>
            </DataSource>
          4. To save the updated value, when the sales rep modifies a value in the detail area, the app should save the business object. Call the Facade.saveObjectAsync framework function in the standard method beforeSaveAsync, which is called before the business object is saved.
          5. Business objects aren’t saved by default because in some cases, you need read-only business objects. To make the business object storable, add this code in the beforeSaveAsync method - var promise=Facade.saveObjectAsync(me);.
            The save function takes the simple properties of the business object and updates the database record by using the mappings defined in the data source.
          6. Save your changes.
          7. To test the changes, build the contracts by running this command. sf modeler workspace build
          8. Refresh the simulator app.
          9. On the Display card, click SHOW ALL DISPLAYS.

          The new UI page opens as shown.

          Master detail page that opens when you click Show All Displays.

           
          Loading
          Salesforce Help | Article