Technical ArticlesNo Comments

default thumbnail
Many times we have to decide the folder location of newly created objects on a specific criteria.
Like, if Part is Manufactured in India, it must be store in India or if part is manufactured in China, it must be store in China folder.How we can do this, here folder location will be derived from the attribute value for country.

Consider, “country” is an attribute on WTPart and it has value set like , INDIA, CHINA, UK etc.

Download the OIR for WTPArt and find and modify as shown in below,

1.  <!– set the folder –>
<AttrValue id=”folder.id” algorithm=”com.ptc.core.foundation.folder.server.impl.FolderPathAttributeAlgorithm”>
<Value algorithm=”wt.rule.algorithm.CaseBranch”>
<Value algorithm=”wt.rule.algorithm.EqualsTest”>
<Attr id=”country”/> <!– Internal name of Attribute value –>
<Arg>INDIA</Arg> <!– If value is INDIA , then folder will be below–>
</Value>
<Arg>/Default/INDIA</Arg>

<Value algorithm=”wt.rule.algorithm.EqualsTest”>
<Attr id=”country”/>
<Arg>CHINA</Arg>
</Value>
<Arg>/Default/CHINA</Arg>

<Value algorithm=”wt.rule.algorithm.EqualsTest”>
<Attr id=”country”/>
<Arg>USA</Arg>
</Value>
<Arg>/Default/USA</Arg>

<Value algorithm=”wt.rule.algorithm.EqualsTest”>
<Attr id=”country”/>
<Arg>UK</Arg>
</Value>
<Arg>/Default/UK</Arg>
<Arg>/Default</Arg>
</Value>
</AttrValue>

2.  <AttrConstraint id=”folder.id” algorithm=”com.ptc.core.rule.server.impl.GatherAttributeConstraints”>
<!– Value algorithm=”com.ptc.core.rule.server.impl.GetServerPreGeneratedValue”/–>
<Value algorithm=”com.ptc.core.rule.server.impl.GetImmutableConstraint”/>
</AttrConstraint>

Save this OIR, upload back in to system. now WTPart will be stored in respective folders based on value of country attribute. if in case the value of Country attribute is blank or some other field, the folder location will be Default folder.

 

Be the first to post a comment.

Add a comment