There is a table called 'To-do' and a field type called 'Assigned to' having field type called 'list

Abhishek Kathe
Mega Guru

There is a table called 'To-do' and a field type called 'Assigned to' having field type called 'list' . when there is new 'to-do' created or 'assigned to' get updated then a new 'to-dos' should be created eg.
I have created 'to-do record 1' and had assiged to 2 users (User 1, User 2)

then simultaneously two new 'to-do records' should be created assigned to 'User 1' and 'User 2' 

1 ACCEPTED SOLUTION

Tushar
Kilo Sage
Kilo Sage

Hi @Abhishek Kathe 

 

Creating a BR should do the work -

 

// retrieve the list of assigned users
var assignedUsers = current.assigned_to.split(",");

// Create new To-do records for each assigned user
for (var i = 0; i < assignedUsers.length; i++) {
    var newToDo = new GlideRecord('To-do');
    newToDo.initialize(); //  fresh record is created
    newToDo.copyValues(current); // copy values from the original record
    newToDo.assigned_to = assignedUsers[i]; // Assign the current user
    newToDo.insert(); // Create the new To-do record
}

 

Thanks,

Tushar

View solution in original post

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @Abhishek Kathe 

 

Creating a BR should do the work -

 

// retrieve the list of assigned users
var assignedUsers = current.assigned_to.split(",");

// Create new To-do records for each assigned user
for (var i = 0; i < assignedUsers.length; i++) {
    var newToDo = new GlideRecord('To-do');
    newToDo.initialize(); //  fresh record is created
    newToDo.copyValues(current); // copy values from the original record
    newToDo.assigned_to = assignedUsers[i]; // Assign the current user
    newToDo.insert(); // Create the new To-do record
}

 

Thanks,

Tushar