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
          Business Logic Contracts

          Business Logic Contracts

          Use business logic contracts to design the behavior of the Consumer Goods Cloud offline mobile app and its features. Business logic contract comprises JavaScript methods that you can use to define how to process and transform data, set access rules, set validations, and perform actions based on certain rules and requirements.

          Unlike other contracts, business logic contracts are editable only as Javascript code. The main block of a business logic contract is the function body. You can define the logic in Javascript code in this body indicated by insertion ranges in the bl.js file. The business logic contract can also optionally receive parameters, and return a value to its caller.

          You can use these Javascript tags to define the business logic function.

          Tag Name Description Value/Pattern Required
          function Specifies the unique name of the businessLogic function. String Yes
          this Specifies the name of the LO, BO, or LU object that this function belongs to. The name value is also part of the business logic filename. String Yes
          kind Specifies the type of object this function belongs to. For example, "businessobject". String Yes
          async Specifies whether the method is asynchronous or synchronous The. load, create and save methods are always asynchronous. If the method is declared as async then the function returns a promise. If async isn’t specified, the method is synchronous. async No
          namespace Indicates whether the method was created in design mode (core) or customizing mode. Possible values are CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade. String Yes
          param Defines a parameter the function accepts. Insert additional param tags to specify more than one parameter. Make sure the value in the param tag matches the function signature. String No
          extends Specifies the base class of the LO, BO, and LU objects that this function belongs to. String No
          maxRuntime Specifies the maximum time taken to execute the Business Logic function. It is measured in milliseconds and supports only integer values. If the max time is exceeded, an error is logged. Integer No
          returns

          Specifies the type and variable name in which the return value is stored.

          The framework evaluates the returns value and generates a return statement from it. When you define your methods, do not use a return statement because the framework takes care of it. You should define only the variable name which should be returned through the returns tag.

          String No

          Create a Business Logic Contract

          Use the sf modeler workspace add command to add new business logic files or methods. Alternatively, manually copy the business logic template files from $workspace/contractSnippets and adapt the files as needed. See Add Modules and Contracts.

          Sample Business Logic Contract

           * @function afterCreateAsync
           * @this BoFastOrderValidation
           * @kind TODO_ADD_BUSINESS_OBJECT_TYPE
           * @async
           * @namespace CORE
           * @param {Object} result
           * @param {Object} context
           * @returns promise
           */
          function afterCreateAsync(result, context){
              var me = this;
              ///////////////////////////////////////////////////////
              //                                                   //
              //   Add your customizing javaScript code below.     //
              //                                                   //
              ///////////////////////////////////////////////////////
              
          var promise=when.resolve(result);
          me.setLoFastOrderProducts(context.jsonQuery.fastOrderProductsForGrid);
          
              ////////////////////////////////////////////////////
              //                                                //
              //   Add your customizing javaScript code above.  //
              //                                                //
              ////////////////////////////////////////////////////
          
              return promise;
          }
          
          • Edit and Access Rights
            Control the edit and access rights for UI elements directly in the UI contract for certain UI elements, and indirectly via business objects and their simple properties.
          • Naming Conventions
            Asynchronous methods and constants for business objects follow specific naming conventions.
          • Getter and Setter Functions
            Define and control access to simple properties, nested objects, and listed objects by using getter and setter functions.
          • Standard Methods
            All business objects have both standard methods and customized methods. The standard methods are automatically available to all objects. For example, LoadAsync and DoValidateAsync.LoadAsync load the simple properties of an object from the database, and loads all nested objects of a business object recursively. DoValidateAsync validates the consistency of an object before it’s saved.
           
          Loading
          Salesforce Help | Article