This extension allows a custom implementation to retrieve the range values of BRA from a custom table or even from an external system. Currently, this is only fully supported for BRA that shows up in a Quote.
Initial Setup
- Find the BRA that would be backed by the script.
- If the field is a predefined field, first find out the ObjectProperty from the main schema that should be overridden. You can do this by searching for it in the schema.owl file, or you may contact us to ask about this.
- If the field itself is already custom, create it in the application-schema-ext.owl file first. For example, the following addition would create a “Custom Attributes” tab in the Quote screen, which contains a field called “Quote Custom BRA”, which currently will never have any option in its drop-down list. Please refer to the General System Features Guide for more details about editing the ontology file.
<owl:NamedIndividual rdf:about="&ase;QuoteCustomAttributes">
<rdf:type rdf:resource="&as;Group"/>
<rdfs:label xml:lang="en">Custom Attributes</rdfs:label>
<as:hasSubGroup rdf:resource="&ase;QuoteCustomAttributesSubGroup"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&ase;QuoteCustomAttributesSubGroup">
<rdf:type rdf:resource="&as;SubGroup"/>
<rdfs:label xml:lang="en">Sub Group</rdfs:label>
</owl:NamedIndividual>
<owl:ObjectProperty rdf:about="&ase;customBRA">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:label xml:lang="en">Quote Custom BRA</rdfs:label>
<as:sequenceID rdf:datatype="&xsd;int">1</as:sequenceID>
<as:group rdf:resource="&ase;QuoteCustomAttributes"/>
<as:subGroup rdf:resource="&ase;QuoteCustomAttributesSubGroup"/>
<rdfs:domain rdf:resource="&as;Quote"/>
<rdfs:range rdf:resource="&ase;customBRAType"/>
<as:enumerable rdf:datatype="&xsd;boolean">true</as:enumerable>
<rdfs:subPropertyOf rdf:resource="&ps;has"/>
</owl:ObjectProperty>
<owl:Class rdf:about="&ase;customBRAType">
<rdfs:subClassOf rdf:resource="&ps;Attribution"/>
<ps:hidden rdf:datatype="&xsd;boolean">true</ps:hidden>
</owl:Class> - Indicate that the BRA should have its values retrieved using a script, and also create the Groovy Script object that it should use. Regardless of if the field is predefined or custom, the same addition to the application-schema-ext.owl file can be used. For example, the following would tell the system to get the value for the “Quote Custom BRA” from a Groovy Script named “Get Custom BRA Values”. Please make sure to set the Groovy Script Type as “GetRangeValues”.
<rdf:Description rdf:about="&ase;customBRA">
<as:synchronizeAllowed rdf:datatype="&xsd;boolean">true</as:synchronizeAllowed>
<as:useScriptForRangeValues rdf:resource="&ase;scriptForCustomBRA"/>
</rdf:Description>
<owl:NamedIndividual rdf:about="&ase;scriptForCustomBRA">
<rdf:type rdf:resource="&as;GroovyScript"/>
<as:objectName rdf:datatype="&xsd;string">Get Custom BRA Values</as:objectName>
<as:hasGroovyScriptType rdf:resource="&as;GetRangeValues"/>
</owl:NamedIndividual> - To make sure that the additions to the application-schema-ext.owl file are reflected in the system, go to Administration > Operation Settings > System Settings and click on the “Start” button for the “Load Customizing” field. Log out and login back to the system after that’s done.
- The Groovy Script that was defined in the application-schema-ext.owl file should now appear in the list at Administration > Master Data Management > Groovy Script. Upload the script file to it. If the script has to reference a Lookup Table, make sure to give it access as well.
Additional Binding Variables
The following binding variable(s) are made available for this extension point, in addition to the common binding variables listed in Groovy Service Introduction - Common Binding Variables.
Variable Name |
Class |
Description |
---|---|---|
activeObject |
String |
The URI of the active object. |
businessType |
BusinessType |
The expected type of the output RangeValue objects. |
salesItemsTree |
SalesItemsTree |
Represents the Quote, it contains the functions that can be used to query the quote and its line items data as well as to modify them. |
currentSalesItemNode |
SalesItemNode |
The SalesItemNode related to the active object. This variable is only included if the active object is a Sales Item or related to it (e.g. Item Header Price Item). |
Expected Output
The script should return a RangeValuesList object, which contains some RangeValue objects. Please refer to the Javadoc for details about these objects.
The RangeValue object has the following fields, as specified in the constructor:
Field Name |
Class |
Description |
---|---|---|
type |
BusinessType |
The type, this should be the businessType binding variable. |
objectId |
String |
The id of the option, this should be unique as it will be saved and used to identify the selected option. For example, if the name has been changed, as long as the id remain the same, the option will be updated automatically. |
objectName |
String |
The object name of the option. If the label is null, the object name will be displayed instead. |
label |
String |
The label of the option. If necessary, for localization the appropriate label can be given based on the user’s language preference defined in the sessionLanguage binding variable. |
Script Execution
The script that has been uploaded for the Groovy Script that was defined for the BRA will be executed automatically when the drop-down of that BRA is opened. The RangeValue objects returned by the script will be displayed for selection.
Comments
0 comments
Article is closed for comments.