The CreatorCon Call for Content is officially open! Get started here.

scratchpad values into a glide query to create a new group based on variables in requested item

levino
Giga Guru

Hi Team

in run script activity which is a part of a workflow, the below does not seem to work, am i missing something?

 

Thanks

Levino

 

 

workflow.scratchpad.Description = current.variables.description;
workflow.scratchpad.NewGroupName = current.variables.new_group_name;

var gr = new GlideRecord('sys_user_group'); //To create group


gr.initialize();

gr.name = workflow.scratchpad.NewGroupName;
gr.type = 'a23a29e8dbec8850304c147a3a96191f';
gr.description = workflow.scratchpad.Description;


gr.setWorkflow(false);
gr.autoSysFields(false);
gr.sys_updated_by = 'admin_sp';
gr.sys_created_by = 'admin_sp';
gr.company = 'd9057fc1db98d7005070326f7c961926';
var grSysid = gr.insert();

 

1 ACCEPTED SOLUTION

Aniket Bhanse
Tera Guru

There is no field called "Company" in the sys_user_group table. Please check if you really have this one. Try commenting out this line 

gr.company = 'd9057fc1db98d7005070326f7c961926';

and then check if your script is working.

 

Let me know if this works

 

View solution in original post

9 REPLIES 9

Aniket Bhanse
Tera Guru

There is no field called "Company" in the sys_user_group table. Please check if you really have this one. Try commenting out this line 

gr.company = 'd9057fc1db98d7005070326f7c961926';

and then check if your script is working.

 

Let me know if this works

 

Hi Aniket

i have commented the line , still does not create the group

Thanks

Levino

Try this code and check initially if the group itself is getting created or not:

workflow.scratchpad.Description = current.variables.description;
workflow.scratchpad.NewGroupName = current.variables.new_group_name;

gs.info("workflow_runscript: "+workflow.scratchpad.NewGroupName);

var gr = new GlideRecord('sys_user_group'); //To create group
gr.initialize();
gr.name = workflow.scratchpad.NewGroupName;
var grSysid = gr.insert();
gs.info("workflow_runscript group_sysid: "+grSysid);

 

This is expected to work. If this works, try adding one one field to your Group table and debug it that way.

 

Let me know if this helps.

Tai Vu
Kilo Patron
Kilo Patron

Hi @levino 

Is there any error message showing for that step in the Workflow Context?

 

Cheers,

Tai Vu