Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi Gurus,
I have one customer requirement that, After approving the list of promotion objects, those object names, numbers and version should be included in a mail notification.
Kindly suggest if there is any work arounnd/customization code available for the same.
Regards,
Mahesh Kumar G
Declare a string workflow variable. Use the below API to get Promotion Targets. Cast the query result to respective object types, get the name and number, store it in the variable - may be append a new line after each entry. Use the variable in activity and emails
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
Thank you
Binesh Kumar
Medtronic - MITG
Hi Binesh,
Thanks for your reply, As i m beginner to customization, Could you please a sample code for The same. I am not sure how to Cast query results to Respective Documents.
Regards,
Mahesh
Mahesh: You can do something like the following starting with Binesh's line to get the promotion request targets
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
while (qLatest.hasMoreElements()) {
Object obj = qLatest.nextElement();
String name;
String number;
if(obj instanceof EPMDocument) {
EPMDocument epmDoc = (EPMDocument)obj;
number = epmDoc.getNumber();
name = epmDoc.getName();
}
else if(obj instanceof WTPart) {
WTPart wtPart = (WTPart)obj;
number = wtPart.getNumber();
name = wtPart.getName();
}
}
Randy
Sorry for delayed reply
Exactly, If you like to add a table for formatting.
public static String getPromotionMembers(wt.maturity.PromotionNotice pn) { | |
String tempStr = null; | |
try { | |
@SuppressWarnings("deprecation") | |
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn); | |
System.out.print("*************Found " + qLatest.size() + " objects in this promotion"); | |
tempStr = "<table><thead><tr style=\"background-color:yellow; font-weight:bold;\"><td style=\"padding:5px; border:.5px solid black;\">Promoted Items</td><td style=\"padding:5px; border:1px solid black; text-align:center;\">Version</td></tr></thead>"; | |
while (qLatest.hasMoreElements()) { | |
Object obj = (Object) qLatest.nextElement(); | |
// System.out.print(obj.getClass()); | |
if (obj instanceof wt.epm.EPMDocument) { |
EPMDocument epmd = (EPMDocument) obj; | |
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">"; | |
tempStr = tempStr + epmd.getCADName() + "</td>" + "<td style=\"padding:5px; border:1px solid black; text-align:center;\">" + epmd.getIterationDisplayIdentifier() + "</td></tr>"; | |
} else if (obj instanceof wt.part.WTPart) { |
wt.part.WTPart wtp = (wt.part.WTPart) obj; | |
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">"; | |
tempStr = tempStr + wtp.getNumber() + "</td>" + "<td style=\"padding:5px; border:1px solid black; text-align:center;\">" + wtp.getIterationDisplayIdentifier() + "</td></tr>"; |
} else if (obj instanceof wt.doc.WTDocument) { |
wt.part.WTPart wtd = (wt.part.WTPart) obj; | |
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">"; | |
tempStr = tempStr + wtd.getNumber() + "</td>" + "<td style=\"padding:5px; border:1px solid black; text-align:center;\">" + wtd.getIterationDisplayIdentifier() + "</td></tr>"; |
} | |
} | |
tempStr = tempStr + "</tbody></table>"; | |
System.out.println("************* Objects undergoing promotion are " + tempStr); | |
} catch (WTException e) { | |
e.printStackTrace(); | |
} | |
return tempStr; | |
} |
Regards
Binesh Kumar
Medtronic - MITG
Hi Binesh & Randy Jones,
Thanks alot for your information.
I would use the same get back to you if any information is needed further.
Regards,
Mahesh
Sure, forgot to mention. If you are using my code, in the activity add {tempStr}. You can also place the compiled code somewhere in codebase and refer that within the workflow
Hi Binesh,
I have used in an Acitivity Start Transition area, while checking the Syntax following errors occurring,
Checking Syntax...
E:\ptc\Windchill\temp\WfExpression3717567.java:85: error: cannot find symbol
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
^
symbol: class QueryResult
location: class WfExpression3717567
E:\ptc\Windchill\temp\WfExpression3717567.java:85: error: variable qLatest is already defined in method executemethod_2(Object[])
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
^
E:\ptc\Windchill\temp\WfExpression3717567.java:85: error: cannot find symbol
QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
^
symbol: variable pn
location: class WfExpression3717567
E:\ptc\Windchill\temp\WfExpression3717567.java:119: error: cannot find symbol
EPMDocument epmd = (EPMDocument) obj;
^
symbol: class EPMDocument
location: class WfExpression3717567
E:\ptc\Windchill\temp\WfExpression3717567.java:119: error: cannot find symbol
EPMDocument epmd = (EPMDocument) obj;
^
symbol: class EPMDocument
location: class WfExpression3717567
E:\ptc\Windchill\temp\WfExpression3717567.java:203: error: cannot find symbol
} catch(WTException e) {
^
symbol: class WTException
location: class WfExpression3717567
Note: E:\ptc\Windchill\temp\WfExpression3717567.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
Syntax check complete.
Thanks & Regards,
Mahesh Kumar G
Please use the below . In wf expressions you have to call the methods by its full package name.
try {
@SuppressWarnings("deprecation")
String tempStr = null;
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult qLatest = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
System.out.print("*************Found " + qLatest.size() + " objects in this promotion");
tempStr = "<table><thead><tr style=\"background-color:yellow; font-weight:bold;\"><td style=\"padding:5px; border:.5px solid black;\">Promoted Items</td><td style=\"padding:5px; border:1px solid black; text-align:center;\">Version</td></tr></thead>";
while (qLatest.hasMoreElements()) {
Object obj = (Object) qLatest.nextElement();
// System.out.print(obj.getClass());
if (obj instanceof wt.epm.EPMDocument) {
wt.epm.EPMDocument epmd = (wt.epm.EPMDocument) obj;
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">";
tempStr = tempStr + epmd.getCADName() + "</td>"
+ "<td style=\"padding:5px; border:1px solid black; text-align:center;\">"
+ epmd.getIterationDisplayIdentifier() + "</td></tr>";
}
else if (obj instanceof wt.part.WTPart) {
wt.part.WTPart wtp = (wt.part.WTPart) obj;
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">";
tempStr = tempStr + wtp.getNumber() + "</td>"
+ "<td style=\"padding:5px; border:1px solid black; text-align:center;\">"
+ wtp.getIterationDisplayIdentifier() + "</td></tr>";
}
else if (obj instanceof wt.doc.WTDocument) {
wt.doc.WTDocument wtd = (wt.doc.WTDocument) obj;
tempStr = tempStr + "<tbody><tr><td style=\"padding:5px; border:1px solid black;\">";
tempStr = tempStr + wtd.getNumber() + "</td>"
+ "<td style=\"padding:5px; border:1px solid black; text-align:center;\">"
+ wtd.getIterationDisplayIdentifier() + "</td></tr>";
}
}
tempStr = tempStr + "</tbody></table>";
System.out.println("************* Objects undergoing promotion are " + tempStr);
} catch (wt.util.WTException e) {
e.printStackTrace();
}
Regards,
Binesh Kumar
Medtronic - MITG
Hi Binesh,
Its working fine, Thank you , Thanks alot.
Regards,
Mahesh
Hi Mahesh,
What steps did you take to make it work?
Regards,
Wagner
Hi Binesh,
I couldn't get that result.
What steps did you take to make it work?
Regards,
Wagner