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
          Datasource Contract Definition

          Datasource Contract Definition

          Use the various elements that constitute a datasource contract to define a datasource.

          Required Editions

          Available in: Enterprise, Performance, and Unlimited Editions

          The DataSource element is the top-level element of a datasource contract.

          <DataSource name="DsBoVisit" businessObjectClass="BoVisit" external="false" editableEntity="Visit" backendSystem="sf" schemaVersion="2.0">

          The table lists the supported attributes in the DataSource element.

          Attribute Description Value or Pattern Required
          name Unique name of the datasource. Literal Yes
          businessObjectClass Name of the assigned business object. Literal Yes
          external

          Indicates whether the datasource contract uses an external datasource. Default value is True, which means that the datasource contract was written by using the external format, also known as the old or manual format.

          External data sources provide Javascript methods to build the Select, Update, Insert, or Delete statements.

          Boolean No
          editableEntity Name of the editable entity or table. Literal No
          distinct Specifies if a distinct SELECT statement is generated. The default value is False. Boolean No
          readOnly Specifies if the Update, Delete, and Insert statements are generated. The default value is False. When the value is set to true, the statements aren’t generated. Boolean No
          schemaVersion Version of the design contract. Literal Yes
          backendSystem Specify sf as the target backend system of the data source. Literal Yes

          You can use these elements in a datasource contract.

          Element Description Required
          Attributes Container element that contains all attributes of a data source. By itself, the Attributes property doesn’t have any attributes, but it can contain Attribute, DerivedAttribute, DateTimeAttribute, and PivotItems sub nodes. For more information, see Attributes. Yes
          Entities Specifies the database table that the data is collected from. By itself, the Entities property doesn’t have any attributes, but it can contain a list of Entity sub nodes. For more information, see Entities. Yes
          QueryCondition

          Use QueryCondition to build the WHERE clause of the SQL query. Each data source can have only one query condition. If the query condition contains a macro, it’s replaced by the parameter of the same name during run time. If you don’t specify a parameter during run time, the macro is replaced by an empty string. Here’s an example:

          <QueryCondition><![CDATA[
                PrdSales.SalesSegmentState = '4'
                    AND PrdProduct.State='4'
                    AND CndMain.ValidFrom <= '#commitDate#'
                    AND CndMain.ValidThru >= '#commitDate#'      
                AND CndMain.PriceType = CndMain.DefaultPriceType
                AND CndMain.PriceListType = CndMain.DefaultPriceListType
                AND CndMain.MetaId = 'ProductPrice'       
                    #addCond_FieldState#
                    #addCond_NewState#
                    #addCond_ForeignProduct#
            ]]></QueryCondition>
          
          Yes
          Parameters

          Specifies the element value which calls the datasource for execution. You can model and use parameters in the JOIN and QUERY conditions to filter the result set. A parameter replaces the corresponding query condition macro during run time. The name attribute in Parameter replaces the corresponding macro in the query condition. For more information, see Parameters. Here’s the name of a pKey attribute.

          <Parameters>
            <Parameter name="callPKey"/>
            <Parameter name="customerPKey" type="TEXT"/>
          </Parameters>
          
          No
          OrderCriteria

          Describes the sorting order of the query result set. These are the attributes in OrderCriteria. All attributes are required and they take the literal type of data.

          • entity - Name of a database table.
          • attribute - Name of a column of the table. Capitalize the first letter of the value.
          • direction - Specify the sorting direction as ascending (ASC) or descending (DESC).

          Here’s an example:

          <OrderCriteria>
            <OrderCriterion entity="PrdProduct" attribute="PKey" direction="ASC" />
          </OrderCriteria>
          
          No
          GroupBy

          Defines the attributes and their order used to create the GroupBy clause of the SELECT statement. The grouping criteria consist of one or more GroupByCriterion elements. For example,

          <GroupBy>
            <GroupByCriterion entity="ClbMeta" attribute="VisitType" />
          </GroupBy>
          
          No
          GroupByCriterion

          These attributes are required in a GroupByCriterion element:

          • entity - Name of the entity or table.
          • attribute - Name of the attribute or column in a table. Capitalize the first letter of the value.
          No
          Macros Macros are shortcuts used in the SQL statements that are replaced at run time. There are framework macros and parameter macros that are customizable at design time. For more information, see Macros. No
          QuickSearchParameters

          Use QuickSearchParameters to specify the columns that the quick search keywords or parameters should be passed in. Contains one or more QuickSearchParameter elements. The generator creates code to add QuickSearchParameter to the SELECT statement if at least one QuickSearchParameter is available. The required attribute in a QuickSearchParameter element is:

          • name - Specifies the name of the attribute to search with. Ensure that the specified attribute exists in the app.

          For example,

          <QuickSearchParameters>
            <QuickSearchParameter name="customer.name"/>
            <QuickSearchParameter name="customer.id"/>
            <QuickSearchParameter name="address.fullAddress"/>
          </QuickSearchParameters>
          
          No
          ConditionalParameters

          Use conditional parameters for optional WHERE conditions. These conditions only apply only if the parameters passed to the data source contain the named parameter.

          The sub nodes of ConditionalParameters are:

          • ConditionalParameter - Use this subnode to define additional conditions if the parameter is passed into the datasource. Specify entity name in the required attribute name for ConditionalParameter.
          • SimpleConditions - Use this subnode to define one or more modeled conditions if a parameter is set. The required attributes are leftSideValue, comparator, rightSideType, and rightSideValue.

            In this example, the parameters passed to the data source during run time contain a parameter named customerPKey and an additional WHERE condition. The WHERE condition compares the JobList.BpaMainPKey column with the value of the customerPKey parameter. You can either pass the comparator as a macro or set it explicitly.

          <ConditionalParameters>
          <ConditionalParameter name="customerPKey">
          <SimpleConditions>
          <Condition leftSideValue="JobList.BpaMainPKey" comparator="#customerPKeyComp#"
          rightSideType="Attribute" rightSideValue="'#customerPKey#'" />
          </SimpleConditions>
          </ConditionalParameter>
          </ConditionalParameters>
          
          No

          Comparison Operators

          Use these comparison operators within the join or WHERE clause.

          Operator Equivalent SQL Operator Description
          EQ = Equal to
          NE <> Not Equals
          LT < Less Than
          LE <= Less Than or Equal to
          GT > Greater Than
          GE >= Greater Than or Equal to
          • Attributes
            Use attributes and its sub elements to specify the columns you want to fetch from the database and build the SQL statement.
          • PivotItems
            PivotItems in a datasource contract cover the differences between schemas.
          • Entities
            Use entities to specify the tables to fetch the data columns from.
          • Parameters
            Parameters are modeled and can be used in the JOIN and QUERY conditions to filter the result set.
          • Standard Macros
            Macros are shortcuts used in SQL statements that are replaced at run time.
          • Sample SQL Statement Generated From a Datasource Contract
            This sample shows the SELECT statement generated for a datasource contract
           
          Loading
          Salesforce Help | Article