"current" isn't defined in UI Action?

grosch
Mega Expert

I've created a new UI Action against the cmdb_model table where I've selected:

  • Active
  • Show update
  • Client
  • Form Link

For the onclick I just specified "showDialog()" and then in the script window, inside my showDialog() function, I'm trying to use the 'current' variable.   I'm getting a runtime error that current isn't a defined variable.

How do I get access to the model that the person is currently viewing from the UI Action?

1 ACCEPTED SOLUTION

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Scott,



"current" is only available server-side. For client-side access to the current record, use g_form.


View solution in original post

4 REPLIES 4

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Scott,



"current" is only available server-side. For client-side access to the current record, use g_form.


manikorada
ServiceNow Employee
ServiceNow Employee

Scott,



Since you are using client side of UI Action, you need to use g_form


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Scott,



Please refer the below link for more info on how to use client & server in one UI action.


Client & Server Code in One UI Action - ServiceNow Guru



Please let me know if you have any questions.


bernyalvarado
Mega Sage

Hi Scott, you can do that by grabbing the sys_id of the record in use by using:



g_form.getUniqueValue()



http://wiki.servicenow.com/index.php?title=GlideForm_%28g_form%29#getUniqueValue



That will give you the sys id of the model



Thanks,


Berny