RE: Any Sample code on how to use the “SaveAs” Object?

Any Sample code on how to use the “SaveAs” Object? I create a new project from template and the “SaveAsObject” event will be triggerred to run the following script. But the script just get the template object but not the new save as object …..

void invokeScript(IBaseScriptObj obj) {
try {

IAdmin admin = session.getAdminInstance();
IEventInfo eventInfo = obj.getPXEventInfo();
IProgram pgm = (IProgram)eventInfo.getDataObject();
mprojname = pgm.getValue(“name”).toString();
mprojnum = pgm.getValue(“number”).toString();
System.out.println(“project name = ” + mprojname);
System.out.println(“project number = ” + mprojnum);

}

catch(Exception e){
System.out.println(“Error on create PIMS project objects” );
}
}

mayleonmay Agile User Asked on June 22, 2016 in Other APIs.
Add Comment
1 Answers

Hi,

I used a Java script with the event but the IEventInfo object is the same.
To get the new object from the save as event, it is necessary to cast it and get the new Number/classID as below

ISaveAsEventInfo saveAsevent = (ISaveAsEventInfo) event;
Integer subclassId = saveAsevent.getNewSubclassId();
String newNumber = saveAsevent.getNewNumber();
IDataObject newObject = (IDataObject) session.getObject(subclassId, newNumber);

Agile Angel Answered on June 22, 2016.
Add Comment

Your Answer

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