Personalizzazione avanzata > Business Logic Customization > Customizing MPMLink > Customizing MPMLink Advanced Lifecycle Management with Object Initialization Rules
  
Customizing MPMLink Advanced Lifecycle Management with Object Initialization Rules
In Product and Library contexts that have been created with the MPMLink Product with Advanced Lifecycle Management application context template, object initialization rules can be used to specify a life cycle template for a new part based on the view that is selected when the part is created. The following procedure describes how to use an object initialization rule to specify which life cycle template is assigned to a new part based on the view that is selected when the part is created.
To complete this procedure, a custom view needs to be created at the site level, which requires site administrator access. Additionally, a custom life cycle template must be created at the application context level, which requires life cycle administrator or application context administrator access.
Procedure
To set up an object initialization rule to specify a life cycle template for a new part:
1. First, create the custom view and life cycle template that are to be used.
a. As a Site administrator, navigate to Site > Utilities > View Administration and create a new view.
b. In the Product or Library context, navigate to Utilities > Life Cycle Template Administration and create a basic life cycle template. Alternatively, use Save As on an existing template.
* 
Only Product and Library contexts that were created with the MPMLink Product with Advanced Lifecycle Management application template support this configuration.
2. Edit the MPMLink Part object initialization rule to specify the view and life cycle templates created earlier.
a. From the Product or Library context, navigate to Utilities > Object Initialization Rules Administration.
b. Right-click on the MPMLink Part rule and select Download. Open the downloaded file in a simple text or XML editing tool. The file contains the following XML code:
<AttributeValues objType="wt.part.WTPart">

<!-- set the lifecycle -->
<AttrValue id="lifeCycle.id" algorithm="com.ptc.core.foundation.lifecycle.
server.impl.LifeCycleTemplateAttributeAlgorithm">
<Value algorithm="com.ptc.windchill.mpml.algorithm.
ViewToLifeCycleAlgorithm">
<Attr id="view.id"/>
<!-- name of the default lifecycle to use -->
<Arg>
<?loc-begin key="BASIC_LIFECYCLE_STATE" match=
"commonLifeCycles.xml:BASIC_LIFECYCLE_NAME" maxlen="30"?>Basic<?loc-end?>
</Arg>

<!-- view name to override lifecycle of -->
<Arg>Manufacturing</Arg>
<!-- lifecycle to override for paired view name -->
<Arg>
<?loc-begin key="MANUFACTURING_LIFECYCLE_STATE" match=
"MPMLinkLifeCycles.xml:MANUFACTURING_LIFECYCLE_NAME" maxlen="30"?>
Manufacturing<?loc-end?>
</Arg>
</Value>
</AttrValue>

</AttributeValues>
c. Add the view and life cycle template names in a pair of argument tags. In this example, the name of the view and lifecycle are:
<Arg>CustomViewName</Arg>
<Arg>CustomLifecycleName</Arg>
These lines must be added after the last argument tag. The following example includes these tags.
<AttributeValues objType="wt.part.WTPart">

<!-- set the lifecycle -->
<AttrValue id="lifeCycle.id" algorithm="com.ptc.core.foundation.lifecycle.
server.impl.LifeCycleTemplateAttributeAlgorithm">
<Value algorithm="com.ptc.windchill.mpml.algorithm.
ViewToLifeCycleAlgorithm">
<Attr id="view.id"/>
<!-- name of the default lifecycle to use -->
<Arg>
<?loc-begin key="BASIC_LIFECYCLE_STATE" match=
"commonLifeCycles.xml:BASIC_LIFECYCLE_NAME" maxlen="30"?>Basic<?loc-end?>
</Arg>

<!-- view name to override lifecycle of -->
<Arg>Manufacturing</Arg>
<!-- lifecycle to override for paired view name -->
<Arg>
<?loc-begin key="MANUFACTURING_LIFECYCLE_STATE" match=
"MPMLinkLifeCycles.xml:MANUFACTURING_LIFECYCLE_NAME" maxlen="30"?>
Manufacturing<?loc-end?>
</Arg>
<Arg>CustomViewName</Arg>
<Arg>CustomLifecycleName</Arg>
</Value>
</AttrValue>

</AttributeValues>
The object initialization rule XML file must always have a single argument for the default life cycle and exactly two arguments for each mapping to be added: the view name and the life cycle template name. If the life cycle name will not be localized, then the <Arg> argument tags containing <?loc> localization strings can be omitted. Otherwise, add localization argument tags for each.
d. Save the XML file to a local drive.
e. From the Object Initialization Rules page, right-click the MPMLink Part rule and select Edit. The Edit Object Initialization Rule window opens. From the XML File field, click Browse and select the edited XML file stored on the local drive. Click OK.
3. Create a new part in the Product or Library to confirm that the object initialization rule correctly applies the desired life cycle template when the object is created with the specified view. In this procedure’s example, parts created with the view “CustomViewName” will be assigned the “CustomLifecycleName” lifecycle template.
For more information, see Manufacturing Life Cycles and Specifying Rules.