MattAPI - Tuesday, July 14, 2009 6:49 PM:
I am trying to write a client-side script that is invoked from either the Part or Document Form. It would execute as an onBeforeUnload 'Form Event' whenever a new Part or Document is created. The goal is to add a sequence # to the item after the form is filed out but before submitting the AML to the server.Section 4.5 in the "Programmers Guide" says that the Item object context for a 'Form Event' is document.thisItem. Indeed, I can use document.thisItem.getProperty('xxx') to access the Item properties. However, none of the other Item methods I try work. For instance, I need to determine what the ItemType is but the GetType() method returns nothing (assuming this is even the right method - documentation is sparse). I also want to add the property for the sequence # before sending the AML to the server but I can't seem to get that to work. I guess my main stumbling block is I don't know how to manipulate an Item object in the DOM.
I haven't been able to find a good example in the cookbook or in other posts here.
MattAPI - Friday, July 17, 2009 12:10 PM:
Ok, so I guess I was doing it correctly after all. After logging out and back-in to Innovator the script now works. Apparently you have to logout before the client-side script changes take effect??Anyway, here is the code:
// What ItemType do we have?
var type = document.thisItem.getType();
// Change the name property before the form is submitted
document.thisItem.setProperty('name', 'New Name');