API to check if any promotables are content type URLData?
- December 19, 2024
- 1 reply
- 1168 views
Version: Windchill 12.1
Use Case: In Promotion Request workflow, check if any of the promotables are WTDocuments with URLData as primary content. If yes, send a notification to a specific group
Description:
In a promotion request workflow, I'm trying to check if any of the promotables are WTDocuments with URLData as primary content and if so, send a notification to a certain group. The only method I've found to possibly allow me to do this is getURLData, which returns a Vector. Below is the code I've tried in a Conditional node in the workflow. Testing by promoting a Document that's content is a URL, it returned result = NO
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.QueryResult queryResult = wt.maturity.MaturityHelper.service.getPromotionSeeds(pn);
boolean isUrl = false;
while (queryResult.hasMoreElements()) {
Object obj = queryResult.nextElement();
if (obj instanceof wt.doc.WTDocument){
wt.doc.WTDocument doc = (wt.doc.WTDocument)obj;
wt.content.ContentHolder ch = (wt.content.ContentHolder)wt.content.ContentHelper.service.getContents(doc);
java.util.Vector urlData = wt.content.ContentHelper.getURLData(ch);
if (!(urlData.isEmpty())) {
isUrl = true;
}
}
}
if (isUrl==true) {
result="YES";
}
else {
result="NO";
}
As a different approach I also tried checking the value of the attribute 2 different ways, but with both of these the workflow doesn't seem to advance beyond the conditional node which houses the code
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.QueryResult queryResult = wt.maturity.MaturityHelper.service.getPromotionSeeds(pn);
boolean isUrl = false;
while (queryResult.hasMoreElements()) {
Object obj = queryResult.nextElement();
if (obj instanceof wt.doc.WTDocument){
wt.doc.WTDocument doc = (wt.doc.WTDocument)obj;
string formatName = doc.getFormatName();
if (formatName == "URL Link") {
isUrl = true;
}
}
}
if (isUrl) {
result="YES";
}
else {
result="NO";
}wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.QueryResult queryResult = wt.maturity.MaturityHelper.service.getPromotionSeeds(pn);
boolean isUrl = false;
while (queryResult.hasMoreElements()) {
Object obj = queryResult.nextElement();
if (obj instanceof wt.doc.WTDocument){
wt.doc.WTDocument doc = (wt.doc.WTDocument)obj;
PersistableAdapter pa = new PersistableAdapter(doc, null, java.util.Locale.US, new com.ptc.core.meta.common.DisplayOperationIdentifier());
pa.load("formatName");
java.lang.String fn = (java.lang.String) pa.get("formatName");
if (fn=="URL Link") {
isUrl = true;
}
}
}
if (isUrl==true) {
result="YES";
}
else {
result="NO";
}
Is this something that's possible or am I totally off the mark? Anything wrong with my syntax/logic? Any help is appreciated.
p.s. I am not a developer/programmer

