<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API to check if any promotables are content type URLData? in Windchill Customization</title>
    <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990352#M9218</link>
    <description>&lt;P&gt;Oh, also noted about&amp;nbsp;&lt;SPAN&gt;getPromotionTargets, that makes sense. I've updated that as well.&amp;nbsp; Thanks again!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Dec 2024 21:34:50 GMT</pubDate>
    <dc:creator>austinrbaird</dc:creator>
    <dc:date>2024-12-20T21:34:50Z</dc:date>
    <item>
      <title>API to check if any promotables are content type URLData?</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990142#M9215</link>
      <description>&lt;P&gt;Version: Windchill 12.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;Description: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;In a promotion request workflow, I'm trying to&amp;nbsp;check if any of the promotables are WTDocuments with URLData as primary content and if so, send a notification to a certain group.&amp;nbsp; The only method I've found to possibly allow me to do this is getURLData, which returns a Vector.&amp;nbsp; Below is the code I've tried in a Conditional node in the workflow.&amp;nbsp; Testing by promoting a Document that's content is a URL, it returned result = NO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;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";
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;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";
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="java"&gt;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";
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this something that's possible or am I totally off the mark?&amp;nbsp; Anything wrong with my syntax/logic? Any help is appreciated.&lt;BR /&gt;&lt;BR /&gt;p.s. I am not a developer/programmer&lt;/P&gt;</description>
      <pubDate>Thu, 19 Dec 2024 21:56:49 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990142#M9215</guid>
      <dc:creator>austinrbaird</dc:creator>
      <dc:date>2024-12-19T21:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: API to check if any promotables are content type URLData?</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990330#M9216</link>
      <description>&lt;P&gt;One thing to start, I think you may want to use&amp;nbsp;getPromotionTargets instead of&amp;nbsp;getPromotionSeeds. Seeds are what the user initially selected to start the promotion request. More things may have been added since the initial selection. Targets will get you everything that is actually set for promotion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you have an error here:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;string formatName = doc.getFormatName();
		if (formatName == "URL Link") {
			isUrl = true;
		}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of:&lt;/P&gt;
&lt;P&gt;if (formatName == "URL Link") {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;if (formatName.equals("URL Link"){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ref:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 18:43:32 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990330#M9216</guid>
      <dc:creator>joe_morton</dc:creator>
      <dc:date>2024-12-20T18:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: API to check if any promotables are content type URLData?</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990351#M9217</link>
      <description>&lt;P&gt;Thanks Joe, that was it. A simple error with a simple solution, thanks for being my 2nd set of eyes.&amp;nbsp; I also had to use the correct syntax java.lang.String instead of string, the compiler called that out easily enough&lt;/P&gt;&lt;LI-CODE lang="java"&gt;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;
		java.lang.String formatName = doc.getFormatName();
		if (formatName.equals("URL Link")) {
			isUrl = true;
		}
        }
}

if (isUrl) {
      result="YES";
}
else {
      result="NO";
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 21:31:07 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990351#M9217</guid>
      <dc:creator>austinrbaird</dc:creator>
      <dc:date>2024-12-20T21:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: API to check if any promotables are content type URLData?</title>
      <link>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990352#M9218</link>
      <description>&lt;P&gt;Oh, also noted about&amp;nbsp;&lt;SPAN&gt;getPromotionTargets, that makes sense. I've updated that as well.&amp;nbsp; Thanks again!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 21:34:50 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Windchill-Customization/API-to-check-if-any-promotables-are-content-type-URLData/m-p/990352#M9218</guid>
      <dc:creator>austinrbaird</dc:creator>
      <dc:date>2024-12-20T21:34:50Z</dc:date>
    </item>
  </channel>
</rss>

