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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to find all objects associated with a Change Notice

RandyJones
20-Turquoise

How to find all objects associated with a Change Notice

I am attempting to add an expression robot to the Change Notice workflow
that will loop thru all the objects associated with that change notice.
Specifically I am interested in the EPMDocuments. I am assuming this
will involve something like this:
1. get a QueryResult of all the Change Notice tasks
2. loop through the tasks
3. get a QueryResult of all objects associated with the task
4. loop through the objects and do the task at hand

Something like this:

wt.fc.QueryResult changeNoticeTasks = ?????
while(changeNoticeTasks.hasMoreElements())
{
   wt.fc.QueryResult taskObjects = ????(changeNoticeTasks.nextElement())???
   while(taskObjects.hasMoreElements())
   {
     object = ???(taskObjects.nextElement())????
   }
}

However I am at a loss as to how to proceed with the magic classes/methods
needed in order to achieve this seemingly simple task. Does anybody have
any hints/tips/code samples?

Thanks
--
4 REPLIES 4
avillanueva
22-Sapphire II
(To:RandyJones)

QueryResult result=ChangeHelper2.service.getChangeActivities(ecn);

while (result.hasMoreElements())

{

WTChangeActivity2
ca=(WTChangeActivity2)result.nextElement();

QueryResult
rResult=ChangeHelper2.service.getChangeablesAfter(ca);

QueryResult
aResult=ChangeHelper2.service.getChangeablesBefore(ca);


Randy,

I assume that your EPMDocuments are either on the affected data or resulting data tables. In that case what you are missing the logic to grabs the Changeactivites giving an ecn number store that in a queryResult, then cycle through the queryResult and extra the contents of the affected/resulting data tables. See code ssamples below:


QureyResult result = ChangeHelper2.service.getChangeActivities(ecn);
While (result.hasMoreElements()) {
WTChanageActivity2 ca = (WTChangeActivity2)result.nextElement();
QueryResult RI_table = changeHelper2.service.getChangeablesAfter(ca);
QueryResult AI_table = changeHelper2.service.getChangeablesBefore(ca);
}


Then you need to cycle through the RI_table and/or AI_table to see if the object is an EPMDocument object,

while ( RI_table.hasMoreElements()){
WTObject object = (WTObject) RI_table.nextElement();
if (object instanceof EPMDocument) {
// do something with it
}

Hope this helps.

Thanks


Alexius C. Chukwuka
IT Analyst, PDP Systems
John Deere Power Systems
Product Engineering Center
*Voice: 319-292-8575
*Mobile: 319-429-5336
*FaxFax:319-292-6282
*E-Mail: -

CONFIDENTIALITY. This electronic mail and any files transmitted with it may contain information proprietary to Deere & Company, or one of its subsidiaries or affiliates, and are intended solely for the use of the individual or entity to whom they are addressed, shall be maintained in confidence and not disclosed to third parties without the written consent of the sender. If you are not the intended recipient or the person responsible for delivering the electronic mail to the intended recipient, be advised that you have received this electronic mail in error and that any use, dissemination, forwarding, printing, or copying of this electronic mail is strictly prohibited. If you have received this electronic mail in error, please immediately notify the sender by return mail.

On 03/11/10 12:01, Randy Jones wrote:
> I am attempting to add an expression robot to the Change Notice workflow
> that will loop thru all the objects associated with that change notice.
> Specifically I am interested in the EPMDocuments. I am assuming this
> will involve something like this:
> 1. get a QueryResult of all the Change Notice tasks
> 2. loop through the tasks
> 3. get a QueryResult of all objects associated with the task
> 4. loop through the objects and do the task at hand
>
> Something like this:
>
> wt.fc.QueryResult changeNoticeTasks = ?????
> while(changeNoticeTasks.hasMoreElements())
> {
>     wt.fc.QueryResult taskObjects = ????(changeNoticeTasks.nextElement())???
>     while(taskObjects.hasMoreElements())
>     {
>       object = ???(taskObjects.nextElement())????
>     }
> }
>
> However I am at a loss as to how to proceed with the magic classes/methods
> needed in order to achieve this seemingly simple task. Does anybody have
> any hints/tips/code samples?
>
> Thanks

The above problem has been solved!!

I appreciate all the very help hints and code examples. In my case all
I am interested in is the resultant epmDocuments. The code I am using
for the robot is this:
========================================================================
//The following query returns all resultant objects for the ChangeNotice
wt.fc.QueryResult resultantObjects = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.ChangeOrderIfc)primaryBusinessObject);
wt.epm.EPMDocument epmDoc = new wt.epm.EPMDocument();
while(resultantObjects.hasMoreElements())
{
     wt.fc.WTObject object = (wt.fc.WTObject)resultantObjects.nextElement();
     if(object instanceof wt.epm.EPMDocument)
     {
          epmDoc = (wt.epm.EPMDocument)object;
          //do my other tasks here...

     }
}
========================================================================


I also had a working robot with the following code:
========================================================================
wt.epm.EPMDocument epmDoc = new wt.epm.EPMDocument();

//get the change notice activities (or tasks)
wt.fc.QueryResult cnActivities = wt.change2ChangeHelper2.service.getChangeActivities((WTChangeOrder2)primaryBusinessObject);

while(cnActivities.hasMoreElements())
{
         wt.change2.ChangeActivity2 ca = (wt.change2.ChangeActivity2)(cnActivities.nextElement());

     //get the resultant objects for the current activity
         wt.fc.QueryResult resultantObjects = wt.change2.ChangeHelper2.service.getChangeablesAfter(ca);

         while(resultantObjects.hasMoreElements())
         {
                 wt.fc.WTObject object = (wt.fc.WTObject) resultantObjects.nextElement();
                 if(object instanceof wt.epm.EPMDocument)
                 {
                         epmDoc = (wt.epm.EPMDocument)object;
                         //do my other tasks here...
                 }
         }
}

========================================================================

However as you can see the first one is simpler. The magic key is the
query that returns all the objects for the change notice:

wt.fc.QueryResult resultantObjects = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.ChangeOrderIfc)primaryBusinessObject);


Again - thanks for all the extremely useful help.
--

Like I recommended to Najanaja, yiou should use the "Add to Project" APIs to collect the information. There you can choose the configurations of the EPM to place in your baseline.
Announcements


Top Tags