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

How to access promotion target comments from a workflow

Level 18

How to access promotion target comments from a workflow

Does anyone know the syntax required to access the comments entered for each promotion object line on a promotion request?

 

Promotion Request Comments.png

I have the syntax necessary to loop through each object in the baseline, but these are the actual EPMDocuments and don't contain the comments that are part of the promotion request (as far as I can tell.)

wt.maturity.StandardMaturityService p = new wt.maturity.StandardMaturityService();
wt.maturity.PromotionNotice pn =(wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult pn_targets;
pn_targets = (wt.fc.QueryResult) p.getBaselineItems(pn);
wt.epm.EPMDocument epmDoc = new wt.epm.EPMDocument();
while (pn_targets.hasMoreElements())
{
    Object obj =pn_targets.nextElement();
    String objType =obj.getClass().getName();
    if (objType.equals("wt.epm.EPMDocument"))
    {
        epmDoc = (wt.epm.EPMDocument)obj;
        String epmNumber = epmDoc.getNumber().toString();
        String epmName = epmDoc.getName();
        String epmCADName = epmDoc.getCADName();
        String epmVersion = epmDoc.getVersionIdentifier().getValue();
        String epmIteration = epmDoc.getIterationIdentifier().getValue();
...

What is the syntax necessary to get each row in the promotion request itself instead of just the objects on the baseline?

10 REPLIES

Re: How to access promotion target comments from a workflow

Hi Tom,

 

 Try using :

pn_targets = (wt.fc.QueryResult) p.getPromotionTargets(pn);

The full description is provided in JavaDocs in class StandardMaturityService and Interface MaturityService.

 

Dmitry.

Re: How to access promotion target comments from a workflow

I still don't see how to retrieve comments from each of the promotion targets.  The pn_targets objects ('obj') are still just EPMDocuments (in my case).  It seems like the command should be something like "obj.GetComments", but for that to work 'obj' would need to refer to the "row" or "item" on the promotion request, not the actual EPMDoc.  As far as I can tell, the EPMDoc itself does not contain the promotion request comments.  What am I missing?

 

Test code:

wt.fc.ReferenceFactory referenceFactory = new wt.fc.ReferenceFactory();
HashMap map = new HashMap(1);
wt.httpgw.URLFactory urlFactory = new wt.httpgw.URLFactory();

Integer i = 1;

wt.maturity.StandardMaturityService p = new wt.maturity.StandardMaturityService();
wt.maturity.PromotionNotice pn =(wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult pn_targets;
pn_targets = (wt.fc.QueryResult) p.getPromotionTargets(pn);
wt.epm.EPMDocument epmDoc = new wt.epm.EPMDocument();
while (pn_targets.hasMoreElements())
{
    Object obj =pn_targets.nextElement();
    String objType =obj.getClass().getName();
    System.out.println("Object Type: " + objType);
    if (objType.equals("wt.epm.EPMDocument"))
    {
        epmDoc = (wt.epm.EPMDocument)obj;
        String epmNumber = epmDoc.getNumber().toString();
        System.out.println("EPMDoc Number: " + epmNumber);
     }
}

Output:

[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03_SHCS.PRT
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03_4.PRT
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03.ASM
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03_3.PRT
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03_1.PRT
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03_2.PRT
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - Object Type: wt.epm.EPMDocument
[WfUserWorkQueue.PollingThread] wt.system.out Administrator - EPMDoc Number: T1370G03.DRW

Re: How to access promotion target comments from a workflow

This one is a bit tricky because the API doesn't spell it out clearly, but I have a solution for you.  You need to access the promotion targets instead of the epmdocument object.  The maturityhelper service will provide this when the (Promotion Notice, Boolean false) param is specified .  In this example, I get the Promotion comments for each of the promotion targets:

 

/*********************************************************
 * Get PromotionNotice
 * Query for PromotionTarget Links (this object accesses the promotion comments)
 * Get Promotion Comments from PromotionTarget
 ************************************************************/

/*Get PromotionNotice*/
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;  
/*Query for PromotionTarget links (Promotion Notice, false)  setting this to false is the key*/
wt.fc.QueryResult promotionObjectLinks = wt.maturity.MaturityHelper.service.getPromotionTargets(pn, false);

 

while(promotionObjectLinks.hasMoreElements()){
  try{
   wt.maturity.PromotionTarget pt = (wt.maturity.PromotionTarget)promotionObjectLinks.nextElement();
   /*Get Promotion Comments and related EPMDocument object from PromotionTarget*/

   String promotionComments = pt.getDescription();  

    wt.epm.EPMDocument epmDoc = (wt.epm.EPMDocument)pt.getRoleBObject();

 

  //Do something with it...
   } catch(Exception wte) {
    wte.printStackTrace();      
    } 
  }

Re: How to access promotion target comments from a workflow

Interesting.  So how do you correlate the comments with the CAD Docs?  Will the query result when the param is false contain the same number of entries as when the param is true?  Will they always be in the same order?

 

Ultimately I'd like to have the table I construct of promotion objects (CAD docs) include a column for these comments.  For that to work I need to correlate each comment with its corresponding CAD object.  Make sense?

Re: How to access promotion target comments from a workflow

Yep, makes sense. 

Q: How do you correlate the comments with the CAD Docs?

A: Get the comment, roleB object and add to some structure (Map, HashMap, etc.) perhaps.  Since number is unique in the system, you could correlate to that value.

String comment = pt.getDescription();

EPMDocument cadDoc = pt.getRoleBObject(); where pt is an instance of PromotionTarget

put in some structure(cadDoc.getNumber(), comment);

 

Q:  Will the query result always return the same number of entries?

A:  Yes

 

Q:  Will the query results always be in the same order?

A:   I assume so since it's reading the baseline, but regardless you can be certain that the comment will be associated to the corresponding CADDoc if you always get the roleB object.

 

 

Re: How to access promotion target comments from a workflow

@TomU Have you thought about using the Promotion Objects table in your Workflow Layout?  It will show the Comments column.

 

1PRa.png

Re: How to access promotion target comments from a workflow

@JeffZemsky,

I'm trying to get this information into the email messages.  See the table at the bottom of this picture:

 

Promotion Request Email.png

Re: How to access promotion target comments from a workflow

Ah - yes so a little less direct.

 

Won't help you now but we are going to be working on some more customization and then configuration points for the notifications.

 

Let me noodle on this some.  Will you be at the PTC/USER sessions coming up?

Re: How to access promotion target comments from a workflow


@JeffZemsky wrote:

Will you be at the PTC/USER sessions coming up?


Yes, I'm planning on being there.