How to Implement the Attribute Valuation Check Business Logic? |
Technical Article |
AbstractThis article details how you can implement the Attribute Valuation Check Business Logic based on the knowledge scripting technology. |
This business logic is called in the PLM New, Edit Properties and Sheet Editor dialogs each time the user manually modify an attribute value. The goal of the BL is to check that the PLM attribute valuation are compliant with some entreprise rules. When the check fails, the BL can generate a user message to help the user to fix the attribute valuation. Two severity of message can be generated:
This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.
PLM Opening ID | PLMAttributesValuationCheck |
---|---|
Customization Intent | Validation |
Execution Context | Client |
The Business Logic can be invoked for at least the listed PLM Component Type. It means that your implementation can safely use the PLM attributes of the default PLM Component.
PLM Component Class Types |
---|
PLMCoreReference |
PLMCoreRepReference |
PLMCoreInstance |
Parameter Names | Types | Read/Write | Comments |
---|---|---|---|
WarningAttributes | list of strings | Write | Output parameter which contains the list of the PLM attribute identifiers which valuation lead to raise a user warning. |
ErrorAttributes | list of strings | Write | Output parameter which contains the list of the PLM attribute identifiers which valuation lead to raise a user error. |
WarningMessages | list of strings | Write | Output parameter which contains the list of the NLS Warning message corresponding to each WarningAttribute. |
ErrorMessages | list of strings | Write | Output parameter which contains the list of the NLS error message corresponding to each ErrorAttribute. |
Important : these lists are accessed in rules with GetAttributeObject API on the context. They must be set on the context with SetAttributeObject at the end of the rule ( see sample ) unless they won't be applied.
The following BL samples show how to:
The resulting UI message will be the following ones:
<Scripts> <Script OpeningID="PLMAttributesValuationCheck " Type="MyPLMProduct" ScriptName="MyProductAttrCheckScript" /> </Scripts>
This family references the script that contains the business logic implementation, which looks like the following CATRule file:
Let Errorlist(List) Let Warninglist(List) Let ErrorMessagelist(List) Let WarningMessagelist(List) Let PublishedMessage(String) Let Supplier(string) Let Description(string) Let MyDescription(string) Let MyId(string) Let InvalidChar(string) Validation=true set Errorlist = Parameters->GetAttributeObject("ErrorAttributes") set Warninglist = Parameters->GetAttributeObject("WarningAttributes") set ErrorMessagelist = Parameters->GetAttributeObject("ErrorMessages") set WarningMessagelist = Parameters->GetAttributeObject("WarningMessages") Supplier = "" if ((ThisObject.V_Supplier==true) and (ThisObject.V_SupplierName == Supplier)) { Validation=false ErrorMessagelist->Append("supplier not valid") Errorlist->Append("V_SupplierName") } Description = "" MyDescription = ThisObject.V_description if (MyDescription == Description) { Validation=false WarningMessagelist->Append("Description should be valuated") Warninglist->Append("V_description") } InvalidChar = "%" if (MyDescription<>NULL) { if (MyDescription.Search(InvalidChar) <> -1) { Validation=false WarningMessagelist->Append("Character % is forbidden in description") Warninglist->Append("V_description") } } MyId = ThisObject.PLM_ExternalID if (MyId.Search(InvalidChar) <> -1) { Validation=false WarningMessagelist->Append("Character % is forbidden in PLM_ExternalID") Warninglist->Append("PLM_ExternalID") } if (Validation == false) { Parameters->SetAttributeObject("ErrorMessages",ErrorMessagelist) Parameters->SetAttributeObject("ErrorAttributes",Errorlist) Parameters->SetAttributeObject("WarningAttributes",Warninglist) Parameters->SetAttributeObject("WarningMessages",WarningMessagelist) }
Version: 1 [July 2007] | Document created |