Workflow scripts are getting cancelled

Preethi26
Tera Contributor

Hi Team,

Am learning on service catalog module as i am new to it. While praticing like workflow is getting cancelled.

Iam trying to create subflow and add user to group via run script. All conditions are working properly but scripts are failing Please help me to learn and fix.

Preethi26_0-1700656302213.png

 

1 ACCEPTED SOLUTION

Hi,

Please update your script like below and see added comments added for your typo error:

var grMem=new GlideRecord('sys_user_grmember');
grMem.initialize();
grMem.user=current.variables.requested_for.toString();
grMem.group=current.variables.add_group.toString();  //previously it was - current.variables.add_group; 
grMem.setWorkflow(false);
grMem.insert();

Also what is the type of Variables on form? Reference or List collector for both variables?

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

4 REPLIES 4

Anil Lande
Kilo Patron

Can you please share your script?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi Anil,

 

For adding users to group i tried

var gr=new GlideRecord('sys_user_grmember');
gr.initialize();
gr.user=current.variables.requested_for;
gr.group=current.variable.add_group;
gr.setWorkflow(false);
gr.insert();

 

for pushing group approval:

answer = [];
answer.push(current.variables.add_group);

 

For both scripts if i use its coming as workflow cancelled for both activity

Hi,

Please update your script like below and see added comments added for your typo error:

var grMem=new GlideRecord('sys_user_grmember');
grMem.initialize();
grMem.user=current.variables.requested_for.toString();
grMem.group=current.variables.add_group.toString();  //previously it was - current.variables.add_group; 
grMem.setWorkflow(false);
grMem.insert();

Also what is the type of Variables on form? Reference or List collector for both variables?

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thanks my bad i missed tostring.

It worked now.

Also i replaced wait for condition with Join and workflow is excueted.

Not sure Why wait for condition causing this issue.

Thank You