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
          Set Edit Restrictions to Competitor Displays

          Set Edit Restrictions to Competitor Displays

          You can set the Competitor Display control as read-only on the mobile app if you don’t want the sales reps to modify the competitor flag setting in display records. Add a SetEARights method to the Display business object and call it in the afterLoadAsync method.

          Required Editions

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

          Manage edit and visibility rights for objects and their properties in business logic with Access Control Language (ACL). In business logic, you can set or remove these rights for all objects or only for specific objects or properties. To add or remove rights, use these methods:

          • acl.addRight(AclObjectType, ElementName, AclPermission)
          • acl.removeRight(AclObjectType, ElementName, AclPermission)

          The parameters for the methods are:

          • type: Use AclObjectType.OBJECT for BO, LO, LU, and LI objects. Use AclObjectType.PROPERTY for simple properties or nested objects.
          • elementName: The name of the simple property or object.
          • permission: Choose from AclPermission.EDIT, AclPermission.VISIBLE, or AclPermission.ALL.
          1. To disable the competitor display control:
            1. In Visual Studio Code terminal, to add a mySetEARights method to the Display module, run sf mdl add, and enter these details.
              ? Select the resource you want to add. businesslogic
              ? Specify a name for the businesslogic: SetEARights
              ? Select the module to which businesslogic 'SetEARights' should be added. MyDisplay
              ? Select a suitable option for businesslogic 'SetEARights'. method
              ? Select the reference object to which you want to add the businesslogic method. BoMyDisplay
              ? Do you really want to create the businesslogic 'SetEARights'? Yes
              Successfully created businesslogic 'SetEARights'.
              The CLI creates the BoMyDisplay.MySetEARights.bl.js contract and adds a reference to the new method in the BoMyDisplay.businessobject.xml contract.
            2. Add this snippet to BoMyDisplay.MySetEARights.bl.js:
              var acl = me.getACL(); acl.removeRight(AclObjectType.PROPERTY, "competitorDisplay", AclPermission.EDIT); 
            3. Save your changes.
            4. To test the changes, build the contracts by running this command. sf modeler workspace build.
            5. Restart the simulator app and verify the changes.

              The image shows the disabled Competitor Display toggle disabled for on the offline mobile app UI.

          2. To set competitor display records entirely to read-only, disable the display object:
            1. Add this snippet to BoMyDisplay.MySetEARights.bl.js:
              if (Utils.isTrue(me.getCompetitorDisplay())) {
                acl.setAce({
                  "objectType" : AclObjectType.OBJECT,
                  "objectName" : "BoMyDisplay",
                  "rights" : AclPermission.EDIT,
                  "grant" : false
                });
              }
            2. Restart the simulator app and verify that the competitor display item is read-only.
            3. Save your changes.
            4. To test the changes, build the contracts by running this command: sf modeler workspace build
            5. Restart the simulator app and verify the changes.

            The image shows the Competitor Display toggle in uneditable state on the offline mobile app UI.

           
          Loading
          Salesforce Help | Article