Insert data into a table via workflow scripts

Arivul
Kilo Contributor

Hello im a complete newcomer with servicenow and im trying to lear it.

My goal its to create a workflow to add a user(sys_user) to use it in a form in a Catalog item.

I create one workflow to test it but when i go to my catalog item it doens show up in the list of workflow.

Any form to test workflows?

how do i access to the data of the catalog item form to insert it into sys_user table?

how do i insert data in table via workflow scrips.

 

Thanks so much for you help.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

In a workflow script activity, you can access catalogue variables via:

 

current.variables.<variable_name>

If you want to insert a record into sys_user, you'd need to use a GlideRecord query to insert the data. Start here for a great rundown of GlideRecord:

GlideRecord Cheat Sheet

 

Something like this may work:

var userGr = new GlideRecord("sys_user");
userGr.initialize();
userGr.user_name = current.variables.userName;
userGr.first_name = current.variables.firstName;
userGr.last_name = current.variable.lastName;
userGr.insert();

Hope that gets you started!

 

Tim

View solution in original post

1 REPLY 1

Community Alums
Not applicable

In a workflow script activity, you can access catalogue variables via:

 

current.variables.<variable_name>

If you want to insert a record into sys_user, you'd need to use a GlideRecord query to insert the data. Start here for a great rundown of GlideRecord:

GlideRecord Cheat Sheet

 

Something like this may work:

var userGr = new GlideRecord("sys_user");
userGr.initialize();
userGr.user_name = current.variables.userName;
userGr.first_name = current.variables.firstName;
userGr.last_name = current.variable.lastName;
userGr.insert();

Hope that gets you started!

 

Tim