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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Get IBA value of Distribution Target in Resulting Objects column

sahmed
1-Newbie

Get IBA value of Distribution Target in Resulting Objects column

Hi,

I want to add one custom column name distribution target. How can I read the values of Distribtuion Target name from WTParts details page and put it into the custom column?

Any Idea..?

Thanks,

Sakil

5 REPLIES 5
BenPerry
13-Aquamarine
(To:sahmed)

Sakil,

I have recently obtained some help to associate all WTParts in the Resulting Objects to a particular DT. My code is below. You might find what you're looking for in here. It contains much more import statements than you need becuase this is just one method in my class. But better too much than not enough. You can remove the ones you don't need.

For example, you might be looking for:

System.out.println("\"" + part.getNumber() + "\" must already be associated with the \"" + target.getName() + "\" Distribution Target");

Full code:

package ext;

import com.ptc.windchill.esi.tgt.ESITarget;

import com.ptc.windchill.esi.tgt.ESINoSuchTargetException;

import com.ptc.windchill.esi.tgt.ESITargetUtility;

import java.io.PrintStream;

import java.text.MessageFormat;

import java.util.ArrayList;

import java.util.List;

import wt.change2.ChangeHelper2;

import wt.change2.WTChangeOrder2;

import wt.epm.EPMDocument;

import wt.fc.Persistable;

import PersistenceHelper;

import wt.fc.QueryResult;

import wt.fc.WTObject;

import wt.part.WTPart;

import wt.query.QuerySpec;

import wt.query.SearchCondition;

import wt.session.SessionHelper;

import wt.util.WTException;

import wt.util.WTPropertyVetoException;

import wt.vc.VersionIdentifier;

import wt.vc.Versioned;

public class WorkflowUtilities

{

public static void assignDT(WTChangeOrder2 cn, String dtNumber) throws WTException {

// Get target (by number) that you want to associate the WTPart to (example: "4" for "DT_NAME")

ESITargetUtility targetUtility = new ESITargetUtility();

ESITarget target = new ESITarget();

try {

target = targetUtility.getTarget(dtNumber, ((wt.inf.container.WTContained)cn).getContainerReference());

} catch (ESINoSuchTargetException e) {

e.printStackTrace();

}

// Get a list of the Resulting Objects of the Change Notice

QueryResult qr = wt.change2.ChangeHelper2.service.getChangeablesAfter(cn);

// Loop through the Resulting Objects and if it is a WTPart, and if it isn't associated to the DT, then associate to the DT

System.out.println("\n\nAttempting to assign WTParts to the \"" + target.getName() + "\" Distribution Target...");

while (qr.hasMoreElements()) {

WTObject obj = (WTObject)qr.nextElement();

if (obj instanceof WTPart) {

WTPart part = (WTPart)obj;

if(!com.ptc.windchill.esi.tgt.ESITargetUtility.isTargetAssociated(part, target)){

com.ptc.windchill.esi.svc.ESIHelper.service.assignTarget(part, target);

System.out.println("\"" + part.getNumber() + "\" has just been associated with the \"" + target.getName() + "\" Distribution Target right now");

} else {

System.out.println("\"" + part.getNumber() + "\" must already be associated with the \"" + target.getName() + "\" Distribution Target");

}

}

}

System.out.println("Done attempting to assign WTParts to the \"" + target.getName() + "\" Distribution Target.\n\n");

}

BenPerry
13-Aquamarine
(To:BenPerry)

Sakil,

On 2nd thought, you might not be able to use this exactly. But you I hope that you'll be able to find what you're looking for in the JavaDoc under com.ptc.windchill.esi.tgt.ESITargetUtility

Hi Ben,

Thanks for your solution. This is to update distribution target of all the parts present in the table. But in my case I have toPTC_Case.PNG update , only for those parts, I have selected . How can I check which parts I have selected in the resulting objects table??

Thanks,

Sakil

BenPerry
13-Aquamarine
(To:sahmed)

I'm not sure how you pass selected items in a table to the source code. I'm not familiar with that.

Hi Ben,

Thanks for your help.

I got the method to get the selected objects.

ArrayList<NmOid> selectedObjects = commandBean.getActionOidsWithWizard();

Top Tags