How to Implement the Attribute Valuation Finalization Business Logic?

Technical Article

Abstract

This article details how you can implement the Attribute Valuation Finalization 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 when the user commits the attribute valuation (action behind the Apply, Finish or OK buttons). The goal of the BL is to check that the whole PLM attributes valuation is consistent with some customer rules. The BL can generate errors which consequence is that the commit action is cancelled. When it occurs, errors are raised and the user has to solve them to be able to commit the modifications.

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 PLMAttributesValuationFinalization
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
ErrorAttributes list of strings Write Output parameter which contains the list of the PLM attribute identifiers which valuation lead to raise a user error.
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 check that the length of the V_description attribute + the length of the PLM_ExternalID attribute is less than 80 characters.

The resulting UI message will be the following one:

PLMAttributesValuationFinalization Error

This family references the script that contains the business logic implementation, which looks like the following CATRule file:

<Scripts>
    <Script OpeningID="PLMAttributesValuationFinalization"
            Type="MyPLMProduct"
            ScriptName="MyProductAttrFinalyzeScript" />
</Scripts>
Let Errorlist(List)
Let ErrorMessagelist(List)
Let PublishedMessage(String)
Let Error(string)
Let Description(string)
Let Id(string)
Let L=0

Validation=true

set Errorlist = Parameters->GetAttributeObject("ErrorAttributes")
set ErrorMessagelist = Parameters->GetAttributeObject("ErrorMessages")
Description=ThisObject.V_description
Id=ThisObject.PLM_ExternalID
L=Description->Length()+Id->Length()
if (L>80)
{
Validation=false
ErrorMessagelist->Append("Too long.")
Errorlist->Append("V_description")
ErrorMessagelist->Append("Too long.")
Errorlist->Append("PLM_ExternalID")
}

if (Validation == false) 
{
Parameters->SetAttributeObject("ErrorMessages",ErrorMessagelist)
Parameters->SetAttributeObject("ErrorAttributes",Errorlist)
}

Recommendations

References

History

Version: 1 [Jul 2008] Document created