cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

Query Attribute of Object Attached to Promotion Request

bwilcox
1-Newbie

Query Attribute of Object Attached to Promotion Request

I am looking for a way to query a particular attributes value of an object attached to a promotion request. We are using Windchill 10.0 M040 and will be updating to 10.1 M030 this weekend.


For example, we have a custom boolean attribute (CertificationControlled)attached to the DefaultEPMDocument object type, and we need to know when objects with that value set to 'Yes' are submitted for promotion within a Promotion Request. I can loop through the objects attached to the promotion request object, but I am not sure how to get the attribute value and check to see if it is true or not. Any help will be appreciated.


Thanks,


Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.

13 REPLIES 13
MikeLockwood
22-Sapphire I
(To:bwilcox)

We do exactly this for the ModelCheck errors (which we label as MC_ISSUES in the info page) attribute using the code shown below.

[cid:image001.png@01CEE6C9.15DB4670]

[cid:image002.png@01CEE6C9.15DB4670]

[cid:image003.png@01CEE6C9.15DB4670]



The LWCNormalizedObject is the latest class used for getting IBA's from anything. It works really well. As a note, I do think it has been replaced by an even better class in 10.2


com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(primaryBusinessObject,null,null, null); obj.load("PR_TYPE"); Object softAttribValue = obj.get("PR_TYPE"); if (softAttribValue instanceof String) { String MyType = (String) softAttribValue;

if (MyType.equals("Electrical")) {

result="IsElectrical";

} else if (MyType.equals("Software")) {

result="IsSoftware";

} else {

result="IsEngineering";

}

}


[Description: C:\Documents and Settings\krista.roy\Application Data\Microsoft\Signatures\tristar_email_signature_files\image001.gif]

Steve Vinyard
Senior Solution Architect

We don't have the ext.alcon class. Is that custom? What version of Windchill are you running? We are on 10.0 M040.



Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.




In Reply to Mike Lockwood:


We do exactly this for the ModelCheck errors (which we label as MC_ISSUES in the info page) attribute using the code shown below.

[cid:image001.png@01CEE6C9.15DB4670]

[cid:image002.png@01CEE6C9.15DB4670]

[cid:image003.png@01CEE6C9.15DB4670]



Steve,


How do you use the LWCNormalizedObject class within a promotion notice? I need to query the IBA values for promotion objects stored within the promotion notice object.


I have the following syntax, within an Expression node, which is working nicely, but I cannot seem to get the IBA value for an attribute associated with the object found during the iteration while loop.


promotionDescription = pn.getDescription().toString();// store the text found in the promotion request description attribute


wt.fc.QueryResult pn_targets = (wt.fc.QueryResult) p.getBaselineItems(pn);


Object myObject = pn_targets.nextElement();
if (objType.equals("wt.epm.EPMDocument")) {
epmObjType = objType.toString();
if (objType.equals("wt.doc.WTDocument")) {
docObjType = objType.toString();
}



Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.

ddemay
1-Newbie
(To:bwilcox)

Assuming you know the IBA value returned is a String for your attribute,
this is less effort to type (good for limited characters) and less thought.



if (softAttribValue instanceof String) { String MyType = (String)
softAttribValue;



Should be.



softAttribValue.toString()



If a string is identified by its parent super class invoking toString on it
returns a pointer to itself already casted as a string w/o checking instance
and allocating another variable.not computer science class, but hey never
hurts to share.



2783

2784 /**

2785 * This object (which is already a string!) is itself returned.

2786 *

2787 * @return the string itself.

2788 */

2789 public String toString() {

2790 return this;

2791 }





result="IsElectrical";

} else if ("Software".equals(softAttribValue)) {

result="IsSoftware";

} else {

result="IsEngineering";

}





Cheers.






ddemay
1-Newbie
(To:bwilcox)

To get the soft type display name you see on screen.



String typeName =
wt.type.TypedUtilityServiceHelper.service.getLocalizedTypeName( pbo,
java.util.Locale.getDefault() );





There is this way for internal logical id.





String externalTypeIdentifier
=wt.type.TypedUtilityServiceHelper.service.getExternalTypeIdentifier(pbo);



if (externalTypeIdentifier.startsWith("WCTYPE|"))

{

// remove the WCTYPE| db does not store it that way

externalTypeIdentifier = externalTypeIdentifier.substring(7);

}





Or.



String typeIdentifer = TypedUtility.getExternalTypeIdentifier( pbo )








I have LWCNormalized Object API in your code to retrieve the IBA value. Check if it works for you




wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;


promotionDescription = pn.getDescription().toString(); // store the text


// found in the


// promotion


// request


// description


// attribute



wt.maturity.StandardMaturityService p = new wt.maturity.StandardMaturityService();


wt.fc.QueryResult pn_targets = (wt.fc.QueryResult) p.getBaselineItems(pn);



while (pn_targets.hasMoreElements()) {


Object myObject = pn_targets.nextElement();


String objType = myObject.getClass().getName(); // get the internal


// name of the


// parent object


// type




if (objType.equals("wt.epm.EPMDocument")) {


isCAD = true;


epmObjType = objType.toString();



com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject((Persistable) myObject, null, Locale.ENGLISH, null);







}


if (objType.equals("wt.doc.WTDocument")) {


isDocument = true;


docObjType = objType.toString();


}


}



Hope this helps !!!!



Thanks,
Shreyas


SimonHeath
4-Participant
(To:bwilcox)

Dear All,

Little point on the code, I understood services should be accessed like this

MaturityHelper.service.getBaselineItems(pn)

However I have noticed this API is deprecated (anyone know why or what is the replacement?)

Also note there are two concepts that need to be understood, seeds and targets. Seeds are in the promotion but not marked for promotion, where as targets will be promoted. The baseline contains items that are seeds make sure you get what you want.

Simon

Simon,


Thanks for the clarification on seeds vs. targets. From what I can tell, in the Windchill 10.0 JavaDoc, the getBaslineItemsmethod is still available, but you access it via wt.maturity.StandardMaturityService. There is a getPromotionTargets method within the StandardMaturityService class that is used for just accessing the targets. I have updated my code, now, to use that method instead.



Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.




In Reply to Simon Heath:


Dear All,

Little point on the code, I understood services should be accessed like this

MaturityHelper.service.getBaselineItems(pn)

However I have noticed this API is deprecated (anyone know why or what is the replacement?)

Also note there are two concepts that need to be understood, seeds and targets. Seeds are in the promotion but not marked for promotion, where as targets will be promoted. The baseline contains items that are seeds make sure you get what you want.

Simon

I tried putting your code into mine, but I get errors when checking the syntax. Here is the error I get:


public static boolean checkEvent (Object _event, Object [] _values)
D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:79: illegal start of expression
^
public static boolean checkEvent (Object _event, Object [] _values)
D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:79: ')' expected
^
public static boolean checkEvent (Object _event, Object [] _values)
D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:79: ';' expected
^
public static boolean checkEvent (Object _event, Object [] _values)
D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:79: ';' expected
^
throws Exception {
D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:80: ';' expected
^
I think it may have to do with the attribute that I am trying to access. It is a boolean attribute. Is there anything special that I have to do to access a boolean vs. a string?


Thanks,


Benjamin Wilcox - IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.




In Reply to Shreyas Atre:



I have LWCNormalized Object API in your code to retrieve the IBA value. Check if it works for you




wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice) primaryBusinessObject;


promotionDescription = pn.getDescription().toString(); // store the text found in the promotion request description attribute



wt.maturity.StandardMaturityService p = new wt.maturity.StandardMaturityService();


wt.fc.QueryResult pn_targets = (wt.fc.QueryResult) p.getBaselineItems(pn);



while (pn_targets.hasMoreElements()) {


Object myObject = pn_targets.nextElement();


String objType = myObject.getClass().getName(); // get the internal name of the parent object type




if (objType.equals("wt.epm.EPMDocument")) {


isCAD = true;


epmObjType = objType.toString();



com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject((Persistable) myObject, null, Locale.ENGLISH, null);







}


if (objType.equals("wt.doc.WTDocument")) {


isDocument = true;


docObjType = objType.toString();


}


}



Hope this helps !!!!



Thanks,
Shreyas



I found an error in my code -- had forgotten a close }. Now, though, I get a different error:


D:\ptc\Windchill_10.0\Windchill\temp\WfExpression493019533.java:48: cannot find symbol
location: class wt.workflow.expr.WfExpression493019533
^
Syntax check complete.


Any ideas?


Thanks,


Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.

Add complet class path for Persistable and local


com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject((wt.fc.Persistable) myObject, null, java.util.Locale.ENGLISH, null);



Thanks,


Shreyas

Thank you. That is what I needed. My code is working very nicely, now. Thank you to all for your help!


Benjamin Wilcox – IntelliServ<sup>™</sup>


PPM & PDM Administrator


IntelliServ provides broadband networking and along-string
evaluation services for high-definition downhole and sub-surface operations
> Get the Facts.

Top Tags