Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get values of variable in UI action

mballinger
Mega Guru

Hello,

How can I access variables using a UI action?

I need to be able to create a new record through a UI Action. My UI Action works, but I have no idea how to access the variables and use them to set fields on the new record. My UI Action currently captures regular fields. How can I get the current variable value and set it in the new record?

UI Action:

var gr = new GlideRecord("table 1");
gr.assigned_to = current.assigned_to; 
gr.short_description = current.short_description; 
gr.description = current.description; 
gr.insert();
action.setRedirectURL(gr);
action.setReturnURL(current);

Thanks!

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You should be able to access the variables by 

current.variables.<variable name>

-Anurag

-Anurag

View solution in original post

4 REPLIES 4

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You should be able to access the variables by 

current.variables.<variable name>

-Anurag

-Anurag

@Anurag Tripathi Thanks! 

How can I trigger a workflow on a successful record creation? If the record is not created, I don't want to trigger the workflow

That you can do from workflow itself

 

-Anurag

-Anurag

Thanks for your response - I am rewritting an existing process. The current UI action collects data and sends to the workflow, triggering the start. What I am doing now is creating the record first and then initiating the workflow. We have 2 different processes, that's the reason for triggering workflow through the UI Action on a successful record creation.