Help Needed with ServiceNow Business Rule: Transfer one task type to another

crstaples
Tera Contributor

Hello ServiceNow Community,

I'm working on a business rule intended to transfer information from a standard CALL ticket, which is what our HelpDesk uses to field all first-contact interactions to another custom task table.  However, I'm encountering challenges in getting it to function as expected. I'm hoping to get some guidance or suggestions from the community.


Objective:
The goal is to transfer specific fields (like caller details, work notes, comments, etc.) from a CALL ticket to a newly created CBO ticket when a choice is selected in the CALL ticket.  My current approach looks something like this:

crstap1_0-1701293611014.png

if (current.description == "") {
gs.addErrorMessage("Description cannot be left blank. Please enter ALL relevant details into the description field. This ticket's history will not be transferred to the new CBO Incident.");
} 
else {
    var gr = new GlideRecord('u_cbo_incident'); 
    gr.initialize();
    gr.caller_id = current.caller_id;
    gr.u_parent_call = current.sys_id;
    gr.location = current.u_location;
    gr.u_alternate_phone = current.u_alternate_phone;
    gr.u_alternate_email = current.u_alternate_email;
    gr.comments = current.comments.getJournalEntry(-1);
    gr.work_notes = current.work_notes.getJournalEntry(-1);
    gr.short_description = current.short_description;
    gr.description = current.description.getHTMLValue();

    var newCboSysId = gr.insert();

    new GlideSysAttachment().copy('Incident', current.sys_id, 'u_cbo_incident', newCboSysId);

    current.comments = "ITS ticket closed, and transferred to CBO: " + gr.number;
    current.state = '7'; // Assuming '7' is the closed state
    current.close_code = "cbo_inc";
    current.update();

    action.setRedirectURL(gr.getLink());
}

 
But this isn't working as I expect it to, mainly the fields aren't being copied over, like "current.caller"  I'm wondering a couple of things here:  Am I approaching this the wrong way?  Is there a simpler way to accomplish this?  Any advice on this topic, or helpful hints where to learn more about this type of task would be very much appreciated.

1 ACCEPTED SOLUTION

DanielCordick
Mega Patron
Mega Patron

Is this a Before BR? You shouldnt be using current.update() 

 

all the fields aren’t being copied or just some of the fields? 

 

 

View solution in original post

3 REPLIES 3

AshishKM
Kilo Patron
Kilo Patron

Hi @crstaples , 

As first two fields are reference type , you can try with .getDisplayValue();

gr.caller_id = current.caller_id.getDisplayValue();
gr.u_parent_call = current.sys_id.getDisplayValue();

 

-Thanks


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

DanielCordick
Mega Patron
Mega Patron

Is this a Before BR? You shouldnt be using current.update() 

 

all the fields aren’t being copied or just some of the fields? 

 

 

Most of the fields aren't being correctly copied.  The one that appears to be is the description field.