Context Object Parameters
Parameter Names | Types | Read/Write | Comments |
---|
WarningAttributes | list of strings | Write | Output parameter which contains the list of the attribute identifiers which valuation leads to raise a user warning.
|
ErrorAttributes | list of strings | Write | Output parameter which contains the list of the attribute identifiers which valuation leads to raise a user warning.
|
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. |
Policy | string | Read | Policy name. |
Note:
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.
Sample
The following sample show how to:
- Check that the description attribute does not contain the ‘%’ forbid character and raises a warning if not checked.
- Check that V_supplier is well valuated and raised an error if not checked.
- Check that the description attribute is valuated. 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)
}