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

Query Attribute of Object Attached to Promotion Request

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 do...

13 REPLIES 13

Query Attribute of Object Attached to Promotion Request

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]



Query Attribute of Object Attached to Promotion Request

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

RE: Query Attribute of Object Attached to Promotion Request

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 do...




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]



RE: Query Attribute of Object Attached to Promotion Request

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 do...

Query Attribute of Object Attached to Promotion Request

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 {

...














Query Attribute of Object Attached to Promotion Request

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 )








RE: Query Attribute of Object Attached to Promotion Request

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


Query Attribute of Object Attached to Promotion Request

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

RE: Query Attribute of Object Attached to Promotion Request

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 do...




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

Announcements
LiveWorx Call For Papers Happening Now!