Aras Innovator Platform

Appendix

This section discusses an approach to set a default Effectivity Scope on the Effectivity Criteria dialog with the corresponding variables based on the default scope.

There can be a variety of business rules to determine the default effectivity scope, such as item classification, item state, user identities, and teams. It may be necessary to pre-populate the Effectivity scope only if a single effectivity scope can be determined. In addition, business-specific logic may change over time.

It is ideal to have a single place where all default rule logic is defined/implemented and retrieved. A server-side method – with parameters as needed – will be an entry point for querying a default effectivity scope. The results can be cached across many requests. This server method can be called from either the client or server-side as shown in the following figure.

For the new server-side method to identify a default effectivity scope:

  • A new server-side method is created and given a name such as effs_getScopeDefaults. This name is abstract enough to expand the method’s functionality as needed. For example, the method can return not only a default scope, but also default values for variables in that scope.
  • The method can return a JSON string. The format may look like:
{
 “scope": {
 “id": “32-hex-id”
 }
}

The value of the scope.id property is the item ID of the effectivity scope item (effs_scope ItemType).

This format provides flexibility to consider future improvements with minimal to no changes.

The method may accept parameters, as needed, for processing of the business logic.

As for the client-side changes to the Effectivity Criteria dialog, the current order of events is outlined as shown in Figure 57.

Requesting the default scope from the server and passing that information along to the Effectivity Criteria dialog to be displayed requires the following modification:

The changes outlined in the previous figure can be accomplished with the following:

In the effs_setEffectivityCriteriaHandl client-side method, make a request to the new server-side method to get default scope details. A client-side request to a server-side method can be achieved using aras.applyMethod(‘effs_getScopeDefaults’,’’);

Construct an object from the response string that would be expected in the dialog EffectivityCriteriaDialog’s constructor (modifications in the constructor would be a next step). You can create an object from a string using JSON.parse().

Take the ‘scope’ property from the just constructed object and pass it as a new additional argument to EffectivityCriteriaDialog’s object creation in the effs_setEffectivityCriteriaHandl client-side method.

After the changes from the steps outlined above, the effs_setEffectivityCriteriaHandl client-side method will look similar to the following:

Open the following file: Innovator/Client/Modules/aras.innovator.core.EffectivityServices/Scripts/EffectivityCriteriaDialog.js

Update the EffectivityCriteriaDialog’s constructor to process the new parameter. To pre-populate the scope field on the dialog form, add the this.scope.id property in the constructor. The resulting constructor may look like the following:

This section outlines executing a Query Definition and applying Effectivity Resolution. This involves:

Retrieving the Query Definition AML

Specifying values for the query parameters of the Query Definition

Executing the Query Definition with Effectivity Resolution

Retrieve Query Definition AML

You can retrieve the Query Definition AML using the following AML query:

<Item type="qry_QueryDefinition” id="%ID%" action="get” levels="2" />
Note
%ID% should be replaced with the ID of the Query Definition that will be executed with Effectivity Resolution.

Specifying Query Parameter Values for the Query Definition

To execute a Query Definition with Effectivity Resolution, values for the appropriate query parameters must be specified. This can be done using the Query Definition’s AML as the starting point.

Open the Query Definition AML retrieved in Section 8.2.1.

Find the “EffectivityScopeId” qry_QueryParameter item. Add the following XML node: <value>%value%</value> with the Effectivity Scope Item ID as the value of the node. In the following example, the ID of the “Aras Part BOM Scope” Effectivity Scope is used.

Prepare the Effectivity Criteria defined in free-form Boolean language in the following format:

<EQ>...</EQ><EQ>...</EQ>...<EQ>...</EQ>

For example:

<EQ><variable id="ID_OF_MODEL_VARIABLE"/><named-constant id="ID_OF_MODEL_ITEM” /></EQ><EQ><variable id="ID_OF_UNIT_VARIABLE"/><constant type="int">11</constant></EQ>
Note
To understand the Scope structure required and to retrieve the correct IDs for each criterion, it is best to run a request to the cfg_GetScopeStructure method. Refer to the Section 5.2.1 of the Aras Innovator 30 - Configurator Services Programmers Guide for further details.

Escape the XML generated in the previous step to make it XML-safe. This can be done using a text editor or an online XML escape tool. Save the resulting escaped string. Find the “EffectivityCriteriaDefinition” qry_QueryParameter item. Add the following XML node: <value>%value%</value> with the escaped string defining the prepared Effectivity Criteria as the value of the node, similar to the following example:

Find the qry_QueryReference item with no parent_ref_id node inside it. This item represents the entry point, or top node, for traversing a structure. Add the following XML node: <filter_xml>...</filter_xml> to provide a start condition. If the Query Definition’s top level (root) Item is an ItemType Item (e.g. Part), use:

<filter_xml>&lt;condition&gt;
&lt;eq&gt;
&lt;property name=&apos;id&apos; /&gt;
&lt;constant&gt;%ITEM-ID%&lt;/constant&gt;
&lt;/eq&gt;
&lt;/condition&gt;</filter_xml>

If the Query Definition’s top level (root) Item is a RelationshipType Item (e.g. Part BOM), use:

<filter_xml>&lt;condition&gt;
&lt;eq&gt;
&lt;property name=&apos;source_id&apos; /&gt;
&lt;constant&gt;%ITEM-ID%&lt;/constant&gt;
&lt;/eq&gt;
&lt;/condition&gt;</filter_xml>
Note
%ITEM-ID% should be replaced with the ID of the Item that is the root item in the structure where effectivity will be applied.

Save the AML response.

Query Definition Execution

  1. Open the saved AML response from step 7 of Section 8.2.2.
  2. Find the root qry_QueryDefinition item and set the value of its action attribute to “qry_ExecuteQueryDefinition”.
  3. The resulting AML can now be run to execute the Query Definition with Effectivity Resolution applied using the set parameters for the resolution.