How to Implement the Attribute Valuation Check Business Logic?

Technical Article

Abstract

This article details how you can implement the Attribute Valuation Check Business Logic based on the knowledge scripting technology.

Business Logic Intent

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:

  1. Warnings: in a such case, the user can follow the edition dialog and an warning is just displayed in the top right corner of the frame.
  2. Errors: in a such case, the user has to fix the error and a pop up window disply the corresponding error.

PLM Opening Definition

This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.

General Information

PLM Opening ID PLMAttributesValuationCheck
Customization Intent Validation
Execution Context Client

Input Objects

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

Context Object Parameters

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.

Implementation Sample

The following BL samples show how to:

  1. Check that the description attribute does not contain the ‘%’ forbid character and raises a warning if not checked.
  2. Check that V_supplier is well valuated and raised an error if not checked.
  3. 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:

 

v_description Attribute

 

v_description Attribute

 

Incident Report Dialog Box

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) 
}   

Recommendations

References

History

Version: 1 [July 2007] Document created