current.task is not updating as intended

SusanSchwar
Tera Contributor
Long story short, I want a change to generate two tasks. I want each task to have a different type. The problem is, when I test out the code, the two tasks that are generated both have implementation as a type. How do I get this to stop?
 
current.state = -5;
current.type = "implementation";
current.short_description = "example 1";
current.description = example1a;

//begin AG
var findAG = new GlideRecord('sys_user_group');
findAG.addQuery('name', 'STARTSWITH', 'exampleAgroup');
findAG.orderBy('name');
findAG.query();
if (findAG.next()) {
    current.assignment_group = findAG.sys_id;
}
//end AG

current.insert();
current.update();

current.type = "testing";
current.state = -5;
current.short_description = "example2";
current.description = "example2b";

//begin AG
var findAG = new GlideRecord('sys_user_group');
findAG.addQuery('name', 'STARTSWITH', 'exampleBgroup');
findAG.orderBy('name');
findAG.query();
if (findAG.next()) {
    current.assignment_group = findAG.sys_id;
}
//end AG



1 REPLY 1

harish41
Tera Guru

Hi,

You are calling current object by utilizing the current.*** . And there will be only one "current" object(I mean you can only update one TASK). So what ever script you are using after current.update() will not work.
If there is another current.update() it will override the above changes but not recommended in a single activity.

I am assuming you might be using workflow to execute the code.
There should be similar separate activity(Catalog Task) in the workflow for other TASK related activities.
Or If you want 2 TASKs, you have to create a separate "Catalog Task" activity in your flow.

Mark as correct and helpful if it solved your query.

Regards,
Harish