Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How do you get the sysid of the current form in a client script?

Not applicable

Client scripts don't like (current) and I'm in need of getting the sysid of the current change form I'm building a script for. What's the client script equiv. to current?

I'm trying to get this to work in an onsubmit

//get workflow helper
var workflow = new Workflow();
//cancel all the workflows, where current is a task record with a workflow context
workflow.cancel(current);
//gs.addInfoMessage(gs.getMessage("Workflows for {0} have been cancelled", current.getDisplayValue()));

4 REPLIES 4

CapaJC
ServiceNow Employee
ServiceNow Employee

g_form.getUniqueValue()


CapaJC
ServiceNow Employee
ServiceNow Employee

I don't think you'll be able to manipulate workflows in your client script without a more complex AJAX call to the server that accesses a Script Include you write that does the work.

Could you just do this in a Business Rule?


neetusingh
Giga Guru

Finding the sys_id of a record in client-side JavaScript can be done using the following call:
var id = gel('sys_uniqueValue').value


CapaJC
ServiceNow Employee
ServiceNow Employee

Don't rely on the value of that DOM element, use g_form.getUniqueValue() instead. The former is not guaranteed to be the same after any given upgrade. The latter is.