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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to get the approver name from a Promotion Request and update a document IBA value with it?

dchaves
1-Visitor

How to get the approver name from a Promotion Request and update a document IBA value with it?

Hello Everyone.

I am trying to get the approver's name from a promotion request and assign it to an IBA inside a wt.doc.WTDocument. Does anyone know a straight forward way to accomplish that? I am not really versed in JAVA so I'd appreciate if you also could provide a code snippet.

I've tried the following inside the "complete" transition from an OOTB promotion request:

1- created a variable called "documenApprover" that matches the IBA internal name.

wt.doc.WTDocument qop = (wt.doc.WTDocument)primaryBusinessObject;
com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(qop,null,null,null);
obj.load("documentApprover");
Object approverValue = obj.get("documentApprover");

documentApprover = approverValue.toString();

I'm getting a message saying that wt.maturity... cannot be cast to wt.doc.....

Anyone can help me here please?

Thank you very much!!

3 REPLIES 3

The reason you're getting the cast error is because the primaryBusinessObject is a PromotionNotice object not a WTDocument. A WTDocument cannot be cast to a PromotionNotice. And neither can a PromotionNotice object be cast to a WTDocument.

KD
12-Amethyst
12-Amethyst
(To:dchaves)

Hi Danilo,

It's really tricky and required more effort to find the approver in Promotion Request from WTDocument.

Instead of that, from Promotion Request 'Approve' task write some code in transition so that system updates the IBA for all Promotable from the Promotion Request workflow.

That way it will be more easy to implement.

Regards,

Kaushik

BineshKumar1
13-Aquamarine
(To:dchaves)

Like Dave said, you are trying to cast the object to wrong type.

First you should get the promotion targets, using the below API

wt.fc.QueryResult pnTargets = wt.maturity.MaturityHelper.service.getPromotionTargets(pbo);


while (pnTargets.hasMoreElements()) {

  Object obj1 = pnTargets.nextElement();
  if (obj1 instanceof wt.doc.WTDocument) {

            wt.doc.WTDocument qop = (wt.doc.WTDocument)obj1 ;

             // then check out the document and update the IBA

   }


   }


Announcements

Top Tags