The CreatorCon Call for Content is officially open! Get started here.

How to populate Request Company field in Requested item and catalog task.

sruthig
Tera Expert

Hi All,

How to populate Request Company field in Requested item and catalog task. I have added run script core activity in workflow to populate request company field. So the same company is to populate in both requested item and catalog task.

 

Regards,

Sruthi

 

1 ACCEPTED SOLUTION

Hi Sruthi,

please add these 2 lines in each catalog task activity advanced script section for whichever task you want it to be populated

var company = current.request.company;

task.<companyField> = company;

find_real_file.png

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

18 REPLIES 18

sruthig
Tera Expert

Hi Jaspal,

 

Company is not a catalog item Variable. It is a form field of the request, requested item and company.

 

Regards,

Sruthi

Thanks Sruthi for the details. So, what should be the request company value set? Is it static or will be dynamic.

Hi Jaspal,

used run script core activity in workflow to populate company field. It's a static value.

Regards,

Sruthi

Hi Sruthi,

So if that would be static then is it getting populated as of now on Request record by default or you want that static value to be updated on Req, RITM and SC Task

If yes then you can use below script in run script activity to update all 3 table records with that field

Run Script:

var company = 'ABC';

//For Request

var requestRec = new GlideRecord('sc_request');
requestRec.get(current.request);

requestRec.<companyField> = company;
requestRec.update();

//For RITM

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sys_id);

ritm.<companyField> = company;

ritm.update();

Catalog Task Activity:

//For Task to be used in catalog task activity advanced script

var company = current.request.<companyField>;

task.<companyField> = company;

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Regards
Ankur

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

Hi Ankur,

I have already set Service Request company field value in Request using workflow.

 

var gr = new GlideRecord('sc_request');

gr.addQuery('sys_id',current.request);
gr.query();
while(gr.next())
{
gr.company='56ecf89cdbcf0c542f1c62d41b961937';
gr.update();

}

 

I want the same value to be populate in Requested item and Catalog task.

Do we can use business rule to achieve this?

Regards,

Sruthi