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” );
}
}
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);