Why SaveAs event not working
Hi, I created a SaveAs event/handler/subsriber…so it is called when we perform a Save As. But can’t get the new attributes. Here is the code, i tried several things that is why there are so much comments/versions..
saveInfo is filled.
subclassId is filled
newNumber is filled
but newObject is NULL
and also newObj is remain NULL – when i tried it to get differently
basically I want to get ‘description’ and ‘productLine’ only during the SaveAs.
Thanks, Feripublic class QualityEscalation extends DAOObject implements IEventAction { private static Logger logger = Logger.getLogger(QualityEscalation.class); ISaveAsEventInfo saveInfo = null; ICreateEventInfo createInfo = null; IUpdateEventInfo updateInfo = null; IUser currentUser = null; public EventActionResult doAction(IAgileSession iAgileSession, INode iNode, IEventInfo iEventInfo) { try { String newPartNumber = ""; ISaveAsEventInfo saveInfo = null; ICreateEventInfo createInfo = null; IUpdateEventInfo updateInfo = null; String saveORCreate = ""; Integer dirtyCellId = null; String dirtyCellValue = ""; HashMap<String, String> valuesMap = new HashMap<String, String>(); String productLine = ""; String description = ""; //IEventDirtyCell dirtyCell = null; currentUser = iAgileSession.getCurrentUser(); if (iEventInfo instanceof ISaveAsEventInfo && saveORCreate.equals("")) { saveInfo = (ISaveAsEventInfo) iEventInfo; ICell cell = null; ISaveAsEventInfo saveAsevent = (ISaveAsEventInfo) iEventInfo; Integer subclassId = saveAsevent.getNewSubclassId(); String newNumber = saveAsevent.getNewNumber(); IDataObject newObject = (IDataObject) iAgileSession.getObject(subclassId, newNumber); // description = saveInfo.getValue(ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION).toString(); IItem newObj = (IItem) iAgileSession.getObject(ItemConstants.CLASS_PART, saveInfo.getNewNumber()); //newPartNumber = newObj.getCell(ItemConstants.ATT_TITLE_BLOCK_NUMBER).getValue().toString(); // cell = newObj.getCell(ItemConstants.ATT_TITLE_BLOCK_PART_TYPE); // newPartNumber = saveInfo.getNewNumber(); // newPartNumber = newObj.getCell(ItemConstants.ATT_TITLE_BLOCK_NUMBER).getValue().toString(); // description = newObj.getCell(ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION).getValue().toString(); // productLine = newObj.getCell(ItemConstants.ATT_TITLE_BLOCK_PRODUCT_LINES).getValue().toString(); // // description = saveInfo.getCell(ItemConstants.ATT_TITLE_BLOCK_DESCRIPTION).getValue().toString(); // // productLine = saveInfo.getCell(ItemConstants.ATT_TITLE_BLOCK_PRODUCT_LINES).getValue().toString(); // saveORCreate = "saveas"; // //check and set new PN if necessary // valuesMap = fillHasMap(newPartNumber, description, productLine); // setPartNumber(valuesMap, saveORCreate); }
If you’re subscriber is set up as a “Pre” event, you cannot fetch the item this way as it doesn’t exist yet. If you need to be a pre-event, you wuld have to use the dirty cells to fetch the create new attributes.
Otherwise, you should be able to use the method you have with a “post” subscriber.