ui action error

samadam
Kilo Sage

I have a UI action with Client checked and a function in the script area. It is not working saying the function is not defined.

 

In On Click I have addItem(g_form.getUniqueValue());

   function addItem(sys_id) {
    var gdw1 = new GlideDialogWindow('acqItem');
    gdw1.setTitle('Add Item');
    gdw1.setWidth(200);
    gdw1.setPreference('sysparm_item_id', sys_id);
    gdw1.render();
}
Is there anything i need to set?
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

you cannot access the sysId here -> addItem(g_form.getUniqueValue());

So update it as this addItem()

Then in script do this

function addItem() {
var gdw1 = new GlideDialogWindow('acqItem');
gdw1.setTitle('Add Item');
gdw1.setWidth(200);
gdw1.setPreference('sysparm_item_id', g_form.getUniqueValue());
gdw1.render();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@samadam 

you cannot access the sysId here -> addItem(g_form.getUniqueValue());

So update it as this addItem()

Then in script do this

function addItem() {
var gdw1 = new GlideDialogWindow('acqItem');
gdw1.setTitle('Add Item');
gdw1.setWidth(200);
gdw1.setPreference('sysparm_item_id', g_form.getUniqueValue());
gdw1.render();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

samadam
Kilo Sage

Thanks a lot. I was duplicating a very old UI action which is working the way it is.