Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello, please tell me what type should be the variable obj ? I found an example of editing a template https://www.ptc.com/en/support/article?n=CS150777 , but there was a problem with the type of variable, tried everything I knew and everything that was recommended, it did not work to pass the test.
CODE:
wt.maturity.PromotionNotice notice = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult results = wt.maturity.MaturityHelper.service.getPromotionTargets(notice);
while (results.hasMoreElements())
{
obj = results.nextElement();
if (obj instanceof wt.doc.WTDocument)
{
var += obj.getName ()+“,”; // var is a global variable
}
}
TESTING:
Checking Syntax...
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_11.java:57: error: incompatible types: Object cannot be converted to Persistable
obj = results.nextElement();
^
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
Syntax check complete.
Ok sorry, just saw your reply there. I think there is something wrong with your code. Is this what you wrote after the suggestion from @zsternal-2
wt.fc.Persistable persistable = (wt.fc.Persistable) resulting.nextElement();
If yes, and it did not work, please post the full code.
yadavankur, this is the whole code, nothing else was added
wt.maturity.PromotionNotice note = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.Query Result results = wt.maturity.Maturity Helper.service.getPromotionTargets (note);
while (results.hasMoreElements ())
{
obj = results.nextElement ();
if (obj instanceof wt.doc.WTDocument)
{
var + = obj.getName ()+ ","; / / var-global variable
}
}
So this is what you are missing
wt.maturity.PromotionNotice note = (wt.maturity.PromotionNotice) primaryBusinessObject;
wt.fc.Query Result results = wt.maturity.Maturity Helper.service.getPromotionTargets (note);
while (results.hasMoreElements ())
{
obj = results.nextElement (); //replace this with below
wt.fc.Persistable obj = (wt.fc.Persistable) results.nextElement();
if (obj instanceof wt.doc.WTDocument)
{
var + = obj.getName ()+ ","; / / var-global variable
}
}
I find your stack trace intriguing though. Is your Windchill instance on the cloud? I am still confused by the presence of this line "com.microsoft.azure.management.apigeneration.LangDefinitionProcessor"
Has the local variable been initialized from and copied into the global variable? These were options when you were creating the local variable.
yadavankur, yes, initialized the variable, maybe the code itself I misunderstood what it does and how to fix it to get the table and display it