Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello Readers ,
I am working with windchill 11.1 version.
I have to start from change notice then add task then add affected and resulting items .
Once i click submit button , i should be able to fetch affected and resulting items .
Since the objects haven't been created yet , they are still in memory , so how to fetch them in method server for doing further customization .
I am trying this by overriding CreateChangeTaskFormProcessor , still not able to get resulting items .
public class CustomChangeNoticeFormProcessor extends CreateChangeTaskFormProcessor {
@Override
public FormResult doOperation(NmCommandBean var1, List<ObjectBean> var2) throws WTException {
List<NmOid> addedItems = var1.getAddedItemsByName("changeTask_resultingItems_table");
System.out.println("added Items : " + addedItems );
//List<NmOid> addedItems1 = nmcommandbean.getAddedItemsByName("changeTask_affectedItems_table");
Iterator<NmOid> iterator = addedItems.iterator();
while (iterator.hasNext()) {
NmOid myOid = (NmOid) iterator.next();
WTObject myObj1 = (WTObject) myOid.getWtRef().getObject();
Solved! Go to Solution.
Finally i got the desired result .
Would like to share .
public class CustomChangeNoticeFormProcessor extends CreateChangeTaskFormProcessor {
FormResult formresult = null;
ArrayList<WTPart> VRid = new ArrayList<>();
@Override
public FormResult doOperation(NmCommandBean var1, List<ObjectBean> var2) throws WTException {
// ************************Code for Getting Part Number ***********
Object myObj = var1.getActionOid().getRefObject();
// ************************Code for Getting affecting items ***********
for (ObjectBean oBean : var2)
{
if (oBean.getObject() instanceof WTChangeActivity2)
{
String[] affectedAddedItemTableObjects = (String[]) oBean.getParameterMap().get("addRows_changeTask_affectedItems_table");
for (String Str : affectedAddedItemTableObjects)
{
String[] arrOfStr = Str.split("#");
for (String a : arrOfStr) {
ReferenceFactory rf = new ReferenceFactory();
WTReference wtref = rf.getReference(a);
Persistable per = wtref.getObject();
WTObject obj= (WTObject) per;
System.out.println("all affected items " + obj.getIdentity());
if(obj instanceof WTPart)
{
WTPart part =(WTPart) obj;
System.out.println("all affected items " + part.getIdentity()+part.getLifeCycleState()+part.getState());
}
else if (obj instanceof WTDocument)
{
WTDocument doc =(WTDocument) obj;
System.out.println("all affected items " + doc.getIdentity()+doc.getLifeCycleState());
}
}
}
}
}
@MIBridges wrote:Hello Readers ,
I am working with windchill 11.1 version.
I have to start from change notice then add task then add affected and resulting items .
Once i click submit button , i should be able to fetch affected and resulting items .
Since the objects haven't been created yet , they are still in memory , so how to fetch them in method server for doing further customization .
I am trying this by overriding CreateChangeTaskFormProcessor , still not able to get resulting items .
public class CustomChangeNoticeFormProcessor extends CreateChangeTaskFormProcessor {
@Override
public FormResult doOperation(NmCommandBean var1, List<ObjectBean> var2) throws WTException {
List<NmOid> addedItems = var1.getAddedItemsByName("changeTask_resultingItems_table");
System.out.println("added Items : " + addedItems );
//List<NmOid> addedItems1 = nmcommandbean.getAddedItemsByName("changeTask_affectedItems_table");
Iterator<NmOid> iterator = addedItems.iterator();
while (iterator.hasNext()) {
NmOid myOid = (NmOid) iterator.next();WTObject myObj1 = (WTObject) myOid.getWtRef().getObject();
I want to add resulting objects to session as I want the resulting items in change notice form processor. But I am finding it difficult to get NmCommandBean object from UIValidator. Can you help me out over here or is there any other alternative to get the Resulting Items from every change activity to change notice form processor?
Finally i got the desired result .
Would like to share .
public class CustomChangeNoticeFormProcessor extends CreateChangeTaskFormProcessor {
FormResult formresult = null;
ArrayList<WTPart> VRid = new ArrayList<>();
@Override
public FormResult doOperation(NmCommandBean var1, List<ObjectBean> var2) throws WTException {
// ************************Code for Getting Part Number ***********
Object myObj = var1.getActionOid().getRefObject();
// ************************Code for Getting affecting items ***********
for (ObjectBean oBean : var2)
{
if (oBean.getObject() instanceof WTChangeActivity2)
{
String[] affectedAddedItemTableObjects = (String[]) oBean.getParameterMap().get("addRows_changeTask_affectedItems_table");
for (String Str : affectedAddedItemTableObjects)
{
String[] arrOfStr = Str.split("#");
for (String a : arrOfStr) {
ReferenceFactory rf = new ReferenceFactory();
WTReference wtref = rf.getReference(a);
Persistable per = wtref.getObject();
WTObject obj= (WTObject) per;
System.out.println("all affected items " + obj.getIdentity());
if(obj instanceof WTPart)
{
WTPart part =(WTPart) obj;
System.out.println("all affected items " + part.getIdentity()+part.getLifeCycleState()+part.getState());
}
else if (obj instanceof WTDocument)
{
WTDocument doc =(WTDocument) obj;
System.out.println("all affected items " + doc.getIdentity()+doc.getLifeCycleState());
}
}
}
}
}