Script PX – Nulling Affected Items on SaveAs

Hello – I am very, very rusty on writing Script PXs and am looking for input on the following scenario.

I am doing a SAVEAS from one Change Object to another. On the second change object (saveto), I would like to iterate through the affected items tab and null out a field for all items. Here is what I have – as you will see I only want this to occur when its a CR saved as another CR, thus the bottom IF statement. Would someone kindly provide some input on how to accomplish this?

 

import com.agile.agileDSL.ScriptObj.IBaseScriptObj;
import com.agile.api.IChange;
import com.agile.api.IDataObject;
import com.agile.api.ITable;
import com.agile.api.IRow;
import com.agile.api.CommonConstants;
import com.agile.api.ChangeConstants;
import com.agile.api.ItemConstants;
import com.agile.agileDSL.ScriptObj.*;
import com.agile.agileDSL.ScriptObj.AgileDSLException;
import com.agile.api.*

void invokeScript(IBaseScriptObj obj)
{
obj.logMonitor(“Entering invokeScript”);
obj.logMonitor(“Change #”+obj.getObjectNumber());
obj.logMonitor(“New #”+obj.getNewNumber());

// Get the CR and CO numbers
IChange savefrom = (IChange) obj.getAgileSDKSession().getObject(IChange.OBJECT_TYPE, obj.getObjectNumber());
IChange saveto = (IChange) obj.getAgileSDKSession().getObject(IChange.OBJECT_TYPE, obj.getNewNumber());

// Set the CO workflow
saveto.setWorkflow(saveto.getWorkflows()[0]);

Integer savefromID =(Integer)(savefrom.getAgileClass().getSuperClass().getId());
Integer savetoID =(Integer)(saveto.getAgileClass().getSuperClass().getId());

//Check for saveas condition CR saved as a CO
if((savefromID.equals(ChangeConstants.CLASS_CHANGE_REQUESTS_CLASS)) && (savetoID.equals(ChangeConstants.CLASS_CHANGE_ORDERS_CLASS))) {
obj.logMonitor(“The source object is a CR.”);
obj.logMonitor(“The new object is a CO. “);
obj.logMonitor(“The Affected Items Tab will not be modified.”)
// Add the CR relationship to the CO relationships table
ITable relationships = saveto.getTable(CommonConstants.TABLE_RELATIONSHIPS);
IRow relationshipRow = relationships.createRow(savefrom);
}

//Check for saveas condition CR saved as a CR – if YES, null the desired fields on Affected Items tab
if((savefromID.equals(ChangeConstants.CLASS_CHANGE_REQUESTS_CLASS)) && (savetoID.equals(ChangeConstants.CLASS_CHANGE_REQUESTS_CLASS))) {
obj.logMonitor(“The source object is a CR.”);
obj.logMonitor(“The new object is a CR. “);
obj.logMonitor(“The Affected Items Tab will be modified.”)
// Iterate through Affected Items table

???

}

}

Agile User Asked on January 25, 2020 in Product Collaboration.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.