Skip to main content
1-Visitor
June 2, 2017
Question

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

  • June 2, 2017
  • 3 replies
  • 2692 views

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

18-Opal
June 5, 2017

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.

12-Amethyst
June 6, 2017

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

1-Visitor
June 6, 2017

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

   }


   }