Skip to main content
1-Visitor
October 18, 2011
Solved

Revising Using Workflow

  • October 18, 2011
  • 7 replies
  • 14614 views

Hi,

I have a need to automate a revise using workflow and was wondering if anyone could tell me the expression I need.

There are two occasions when I need it, once in a promotion workflow and once in the change notice workflow.

Regards,

Toby

Best answer by Toby.Pettit

I have not tested it (like I said I had it working properly with changeables) but something like this should work:

try

{

wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;

wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getBaselineItems(pn);

while (qr.hasMoreElements()) {

wt.vc.Versioned obj = (wt.vc.Versioned) qr.nextElement();

wt.vc.Versioned newObject = wt.vc.VersionControlHelper.service.newVersion(obj);

wt.fc.PersistenceHelper.manager.store(newObject);

}

}

catch (wt.util.WTException ex)

{

}

Toby

7 replies

1-Visitor
October 18, 2011

VersionControlHelper.service.newVersion. I'm not sure if the new version is persisted.

Don't put this directly in the expression. Put it in your own class and method and call that method from the expression. Later, if you decide you don't want to auto-revise, you can simply comment out the .newVersion stuff inside your method.

1-Visitor
October 18, 2011

That will suit me fine as a back up however my company is fairly limited in what we are allowed to do outside of the Windchill GUI due to imposed restrictions from our parent. The reason being that it makes it harder to upgrade and they want to keep maintenance to a minimum.

If anyone knows of a way I can do it in an expression that would be great? Otherwise thanks Matthew and I'll try and make the business case.

Regards,

Toby

1-Visitor
October 18, 2011

In an expression, you have access to at least two things.

1. ObjectReference self

2. WTObject primaryBusinessObject

Try something like:

primaryBusinessObject = (wt.fc.WTObject)wt.vc.VersionControlHelper.service.newVersion((wt.vc.Versioned)primaryBusinessObject);

primaryBusinessObject = (wt.fc.WTObject)PersistenceHelper.manager.save(primaryBusinessObject);

You should probably do this inside a try catch and even inside a Transaction. One possible reason this would error is because somebody has not checked in the business object before the expresison fires.

1-Visitor
October 18, 2011

Both suggestions do not produce errors. I will test tomorrow morning to check I get the behaviour I want. Thanks guys!

1-Visitor
October 19, 2011

Well I tried it and it occurred to me I may not have worded the question properly. I want the promotion request to revise the objects in the promotion. I need this because I need to to promote to a state (implementation) and then revise to the Production state (going from a numeric to a mil std revision). The ERP connector is then triggered but the change in revision scheme is a requirement to put it into the Production life cycle state in our ERP system.

So, and I think I know the answer, can I revise the content of the promotion request within a workflow without customisation?

Toby

22-Sapphire I
October 19, 2011

This is available OTB with 10.0 M020

10-Marble
April 19, 2012

Mike,

I've looked in the Workflow Template Administrator in v10.0 M020, and (apart from it taking ages to load compared with the previous versions...) I could not see any new additions to the UI to do a Revise action automatically in the Method Robot or Expression Robot. Can you be more explicit about where the new functionality in v10.0 is made available OOTB ?

ta'

Nick

1-Visitor
April 20, 2012

This has been an interesting discussion. I just tried to find out how to accomplish this in Windchill 10.0.

In Windchill 10.0, promote and revise simultaneously is acheived by combination of a preference and some customization -

Preference is 'Automatic Revision Mode'

A workkflow expression is required to be added with a new API -

com.ptc.windchill.enterprise.maturity.PromotionNoticeWorkflowHelper.revisePromotables(..)

This is also documented in Windchill 10.0 Customization Guide: Procedure - Adding Automatice Revisioning.

1-Visitor
November 23, 2011

I'd like to do this too. Currently I have a task that requires the initiator to do this manually. It would be really nice if the workflow would revise the object without interaction from the initiator.

I have the same issue, Toby. We have one revision scheme for New and R&D states in the lifecycle, but another for Released objects. I promote an object to a temporary state (Pre-released) then revise the object to Released with the new revision scheme. I am using Windchill 9.1 M060 and may go to Windchill 10, but not for some time.

1-Visitor
November 23, 2011

Are you wanting to revise just a single object, the objects attached to a promotion request or changeables attached to a change request?

I managed to get it to revise all the objects attached to a change request - the code is quite easily changed to revise baselines of a promotion request. If you are revising a single object Amol's answer is just fine.

I do not have access to the code right now for the others but I will tomorrow morning (GMT).

Toby

1-Visitor
November 23, 2011

All the objects attached to the promotion request.

Shawn

1-Visitor
April 6, 2015

Greetings All,

I've been trying to set up a promotion process to revise an object so that we'd have a formalized, documented reason for the revision. This has been working however I noticed that when the promotion objects are revised, the old versions no longer maintain they're original state (released - no modify rights) but take on the new state (rework required - can be modified) that the new version moves to. This has become an issue because users have been able to inadvertently check out a previous revision as it is left in the modifiable state after completion of the promotion request. This is not what I want. As a note, we do have the 'allow checkout of non-latest iterations' set to 'Do not allow...' Not sure why that is not stopping the checkout of previous iterations.

In contrast, if we simply do a right-click>revise from admin - the old state (released) is maintained on the old version and the new version is in the new state (rework required). This is what I want.

Any help would be greatly appreciated.

Marc

Here is the default code for revisioning in the OOTB 10.2:

wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;

try

{

java.util.Locale locale = wt.session.SessionHelper.getLocale();

com.ptc.core.ui.validation.UIValidationResultSet set= com.ptc.windchill.enterprise.maturity.PromotionNoticeWorkflowHelper.revisePromotables(pn, pn.getCreator(), locale);

reviseValidationMsg= com.ptc.windchill.enterprise.maturity.validators.PromotionTargetsReviseValidator.getReviseResultSetMessage(set, locale);

if (!reviseValidationMsg.isEmpty() )

result="Partial";

else

result="Full";

}

catch( Exception wte )

{

wte.printStackTrace();

}

*Update*

It looks like this code won't run without the code that promotes the objects ahead of it. This is clearly a problem as I think the solution to my problem is to do the revision before the promotion. Anybody know how to do a revision before a promotions?

1-Visitor
April 14, 2015

Does anybody out there know why the above conditional routing expression, that revises the object, won't work unless it is preceded by the following conditional routing expression that promotes the object? I'd like to revise the object before it's promoted so as to preserve the state of the original promotion object.

wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;

try

{

wt.util.WTProperties props = wt.util.WTProperties.getLocalProperties();

VERBOSE = props.getProperty("wt.maturity.verbose",VERBOSE);

}

catch( Throwable t )

{

}

try{

wt.maturity.MaturityServerHelper.service.promoteTargets (pn);

/* If any of the promotion targets are Advanced Configurable Generics the

* baseline used during collection needs to be set on the generic as the

* default baseline to properly support Options and Variants. If none of

* the promotion targets are Advanced Configurable Generics, this method will

* simply return.

*/

wt.maturity.MaturityServerHelper.setDefaultBaselineForGenerics(pn);

result="Approved";

} catch (wt.maturity.MaturityException me){

if ( VERBOSE )

me.printStackTrace();

errorMsg=me.getMessage();

result="Rejected";

}

11-Garnet
February 9, 2016

Is there an option to do essentially this same thing through a Change Notice workflow?  We are testing using an Alpha and Numeric versioning schema and without an automated revise when moving from Prototype to Full Production (Released) we need to follow a manual process to move from the Alpha to Numeric revision.