Company field is not auto populating in the SCTASK record of RITM

Amith P
Kilo Contributor

The Company field is not inheriting/auto-populating in the SCTASK record even though the field is present in the RITM.

User raises the request and RITM gets created in which the company will get added automatically based on the user.

I have added the same Company field to the task which got created from the RITM. But the value is not getting captured automatically in the 'Company' in SCTASK.

RITM:

find_real_file.png

 

 

SCTASK:

find_real_file.png

1 ACCEPTED SOLUTION

Hi Amith,

the field is newly created on sc_task or sc_req_item table?

if yes on RITM and if it is populated on RITM level during catalog item submission then it should be visible on task form if you are adding it from dot walk

if above field is newly created on sc_task then you need to set it via script

have before insert business rule on sc_task and have following script

var item = new GlideRecord('sc_req_item');
item.addQuery('sys_id', current.request_item);
item.query();

if(item.next())
current.company = current.request_item.company;

// pick the company to be populated on sc_task from sc_req_item

// current.item is not valid since sc_task doesn't have that field
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

(function executeRule(current, previous /*null when async*/) {

    var item = new GlideRecord('sc_req_item');
    item.addQuery('sys_id', current.request_item);
    item.query();

    if(item.next())
        current.company = item.company;
        }
)(current, previous);

 

Try this.

Just put the BR on Update so that you dont need to write current.update()

Thanks Omkar. Its working perfectly.

Hi Amith,

the field is newly created on sc_task or sc_req_item table?

if yes on RITM and if it is populated on RITM level during catalog item submission then it should be visible on task form if you are adding it from dot walk

if above field is newly created on sc_task then you need to set it via script

have before insert business rule on sc_task and have following script

var item = new GlideRecord('sc_req_item');
item.addQuery('sys_id', current.request_item);
item.query();

if(item.next())
current.company = current.request_item.company;

// pick the company to be populated on sc_task from sc_req_item

// current.item is not valid since sc_task doesn't have that field
}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks Ankur. Its working perfectly.