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

Hi Tai

no error message is showing

Ankur Bawiskar
Tera Patron
Tera Patron

@levino 

script looks good to me.

ensure you use correct field names etc

what debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur

yes i am using the correct field names.

 

pleas advise what debugging i need to do

@levino 

try to add gs.info() and debug

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Danish Bhairag2
Tera Sage

Hi @levino ,

 

As mentioned by aniket there is no field for company in Group table ,hence it is failing. If u intend to populate vendor field in group table then use gr.vendors instead of gr.company.

 

Attaching the screenshot of available fields in group table.

 

Thanks,

Danish