Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

'create known error article' it should trigger approval to the problem task Assignment.

Anupriya_11
Tera Contributor

Hi Team,

I have requirement where after submission of 'create known error article' it should trigger approval to the problem task Assignment, can someone help me that how can we achieve this. As i have tried to customize new workflow in the approval activity  as below but its not working , could you help me to fix this issue:

 

var task1 = new GlideRecord('problem_task');
task1.addQuery('problem', current.source);
task1.addQuery('problem_task_type', 'rca'); 
task1.query();

if (task1.next()) {
 
    var assignmentGroupSysId = task1.assignment_group;

    if (!assignmentGroupSysId) {
        gs.error('Assignment Group is missing on the Task related to the Problem');
        return;
    }

   
    var groupMembers = new GlideRecord('sys_user_grmember');
    groupMembers.addQuery('group', assignmentGroupSysId); // Get members of the Assignment Group
    groupMembers.query();

  
    while (groupMembers.next()) {
        var approver = groupMembers.user; // User from the group member record

       
        var approval = new GlideRecord('sysapproval_approval');
        approval.initialize();
        approval.setValue('target', task1.sys_id); // Link the approval to the Problem Task
        approval.setValue('state', 'requested'); // Requested state
        approval.setValue('approver', approver); // Set the approver (group member)
        approval.setValue('type', 'approval'); // Type is approval
        approval.setValue('requester', current.requester); // Optionally, set the requester (if available)
        approval.insert(); // Insert the approval record
    }
0 REPLIES 0