cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

ECN set state on certain changeables

ColinBull
1-Visitor

ECN set state on certain changeables

Hi guys.

Just want some tips here. I want to use an expression in the ECN workflow

to set a state of INWORK for EPM and Documents only in the changeables in the ECN workflow. I have tried some code but i get exception errors in the robot it is trying to run highlighted in BOLD. Can anyone help?

//Set State of Main Object (Document or Part) back to Inwork.
wt.fc.QueryResult resultingChangeableQr = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.ChangeActivityIfc) primaryBusinessObject);
System.out.println("(MM) ##### Total Doc Found:-" + resultingChangeableQr.size() );
while( resultingChangeableQr.hasMoreElements() )
{
java.lang.Object obj = resultingChangeableQr.nextElement();
if(obj instanceof wt.doc.WTDocument)
{
System.out.println("(CB) Document Found");
wt.fc.Persistable changeable = (wt.fc.Persistable) resultingChangeableQr.nextElement();
changeable = (wt.fc.Persistable) wt.lifecycle.LifeCycleHelper.service.setLifeCycleState( (wt.lifecycle.LifeCycleManaged)changeable, wt.lifecycle.State.INWORK );

}
if(obj instanceof wt.epm.EPMDocument)
{
System.out.println("(CB) CAD Document Found");
// wt.fc.Persistable changeable = (wt.fc.Persistable) resultingChangeableQr.nextElement();
// changeable = (wt.fc.Persistable) wt.lifecycle.LifeCycleHelper.service.setLifeCycleState( (wt.lifecycle.LifeCycleManaged)changeable, wt.lifecycle.State.INWORK );
}
} //End of While
System.out.println("(MM) ##### Executed:-" + resultingChangeableQr.size() );
7 REPLIES 7

Hi Colin



You are using nextElement() once for checking the instance and second time
before setting the state.

wt.fc.Persistable changeable = (wt.fc.Persistable)
resultingChangeableQr.nextElement();
should be coded as

wt.fc.Persistable changeable = (wt.fc.Persistable) obj;



Just to improve the code, please try to use WTObject instead of obj and
LifeCycleManaged instead of Persistable. And as you set the same state for
both doc and cad, I am unsure why check the instanceof before setting the
state. And try to use helper classes from the expression robot instead of
entire java code inside expression robot. This will be handy when you go for
upgrades(major as well as MORs).



Thank you and have a great time.

Best Regards

Swamy Senthil

Principal Solutions Architect

973 216 0456(M); 973 324 2729(W); 866 908 6561(F)

swamy.senthil@swasen.com

Swasen Inc (

Colin,

Here's a class file that I think will do something very similar to what
you need. See the method, setResultingItemsState(),

Pass this method a ChangeNotice object and it will:

Query it for the ChangeActivity.

Once found, the ChangeActivity is queried for Resulting Items for a
WTDocument. In our process the WTDocument is the object whose state is
used for the target state for the other Resulting Items objects so we
first find the WTDoc on the Resulting Items and then get its state.

Next we reset the CA query and go thru it again. Any object that is not a
WTDoc will then have it's state set to match the WTDoc. If that object is
a WTPart it too is queried for EPMDocs. Any associated EPMDoc whose
number (less extension - .prt, .asm, etc) and Version match the WTPart
also have their states set to match the WTDocument's state.

Hope this helps

David




This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.

If this email is from an unknown source, please simply delete this email.

If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.

+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".

Additional instructions and options on how to receive these attachments can be found at:

This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.

If this email is from an unknown source, please simply delete this email.

If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.

+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".

Additional instructions and options on how to receive these attachments can be found at:

This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.

If this email is from an unknown source, please simply delete this email.

If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.

+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".

Additional instructions and options on how to receive these attachments can be found at:

This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.

If this email is from an unknown source, please simply delete this email.

If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.

+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".

Additional instructions and options on how to receive these attachments can be found at:

This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.

If this email is from an unknown source, please simply delete this email.

If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.

+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".

Additional instructions and options on how to receive these attachments can be found at:

Announcements


Top Tags