Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Does anyone know the syntax required to access the comments entered for each promotion object line on a promotion request?
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?
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.
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
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();
}
}
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?
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.
@TomU Have you thought about using the Promotion Objects table in your Workflow Layout? It will show the Comments column.
I'm trying to get this information into the email messages. See the table at the bottom of this picture:
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?
@JeffZemsky wrote:
Will you be at the PTC/USER sessions coming up?
Yes, I'm planning on being there.
Hello,
who knows, where promotion comments are stored in database?
My customer wants to increase the number of carracters.
Thanks and regards
Stefan
Hello, JeffZemsky, please tell me how you added Promotion Objects table in your Workflow Layout?
I tried to do that https://community.ptc.com/t5/Windchill/Where-to-write-the-code/td-p/630464 , but it didn't work.
That's what I did https://community.ptc.com/t5/Windchill/What-type-should-be-the-variable-obj/m-p/633206#M60480
@VladiSlav it is purely through configuration.
First you edit the Workflow Activity Templates -> Go to Templates and Task Form Templates. There is an OOTB example in Review/Approve Promotion Request
You can configure the Workflow Activity by creating Tabs and then populating the Tabs with Actions and Tables/Attributes all through the UI
The final step is to set your workflow activity to use this template. Note that once you do this any updates to your template are dynamic and show immediately in any running activity that uses the template.
Did you configure your table view on your Promotion Objects to show the Comments column?
JeffZemsky, I didn't set up the table view, I wanted to add the "Promotion Objects" table to the "Task" page":
Tell me, please, with the help of Your example it is possible to implement it?