Update sc task work notes

ashaki
Kilo Expert

Hi Community, I have a requirement to copy the ticket number from the rm_story to the sc task work notes whenever the story is completed. We currently have a ui configuration to create a story from a catalog task and whenever the story is completed the task is close. I would like to copy the story number to the task work notes but my script is not working. Any help would be appreciated. Below is the script, please let me know what is wrong.Thanks

Business Rule 

Table - sc_task table

After - insert/update

    var re = new GlideRecord('rm_story');
    re.addQuery('sys_id', current.parent);
    re.query();
    if(re.next()) {
        if(re.state.changesTo('20')){
            var rt = new GlideRecord('sc_req_item');
            rt.addQuery('requested_item', current.sys_id);
            rt.work_notes =  "Story" + re.number;
            rt.update();
        }
    }

1 ACCEPTED SOLUTION

ok. The business rule will be on the rm_story table with a condition: State - changeto - Closed

The script will look something like this:

var gr = new GlideRecord('sc_task');
gr.get(current.initial_task);
gr.work_notes = "Story " + current.number;
gr.update();

View solution in original post

3 REPLIES 3

Michael Fry1
Kilo Patron

The ui action that creates a story from a SCTask, is parent populated with the SCTask or the RITM?

The business rule will need to run on the rm_story table, as that's where the update is occurring and the state is changing, but not sure how you're tied to the RITM/SCTask to advise beyond that.

The ui action populates the sctask number on the rm_story table in a field call initial_task.

 

ok. The business rule will be on the rm_story table with a condition: State - changeto - Closed

The script will look something like this:

var gr = new GlideRecord('sc_task');
gr.get(current.initial_task);
gr.work_notes = "Story " + current.number;
gr.update();