CycleOp - Thursday, June 30, 2011 4:32 AM:
Hi all,
I have a list attribute on a form. I wrote an method and attached it as an action to the ItemType.
When I try the following code I get errors. Seems I am not retrieving the attributes on the form as I should.
Here the code:
var iNumber = document.getElementById("item_number");
alert(iNumber.value); //returns null
Any ideas ?
Sagi
Ronan - Thursday, June 30, 2011 8:38 AM:
Hi,
Does the item_number id exist in your HTML DOM?
CycleOp - Thursday, June 30, 2011 9:48 AM:
Ok, I got it, with the help of Rolf from Aras (Thanks Rolf!).
When running an action (from menu - select the "actions" menu and run your method - You do not have access to the "document" element.
Instead you get the "this" to the Item itself. So the code goes like that:
var itemLock = this.fetchLockStatus();
alert (itemLock);
if (itemLock > 1 || itemLock < 0)
{
top.aras.AlertError("cannot update. Locked by someone else");
return;
}
var amlcmd;
if (itemLock === 1)
{
amlcmd = top.aras.newIOMItem(this.getAttribute("type",""),"update");
}
if (itemLock === 0)
{
amlcmd = top.aras.newIOMItem(this.getAttribute("type",""),"edit");
}
amlcmd.setID(this.getID());
amlcmd.setProperty("issuestatus","Cancelled");
amlcmd.setAttribute("serverEvents","0");
amlcmd = amlcmd.apply();
return amlcmd;