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

Jaspal Singh
Mega Patron
Mega Patron

Hi Sruthi,

 

In the very first run-activity you can store the value use 

workflow.scratchpad.locis=current.variables.variable_name;

 

Then use in the sctask activity code as below

task.locis=workflow.scatchpad.locis; //locis is a field on Catalog task table

 

For RITM use run-script use below

current.locis=workflow.scratchpad.locis//locis is a field on RITM table

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sruthi,

Is the company a variable on catalog item? what is the type of variable?

you want that to be populated on Catalog Task and RITM?

Do you have location field on RITM and SC Task table to hold this value?

Regards
Ankur

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

Hi Ankur,

Company is request form field. Not Catalog item variable.

Regards,

Sruthi

Hi Sruthi,

how company field on Request is populated?

I assume you are having some default value for this

please have this code to update company on RITM table

Sample script for workflow run script on Catalog item

var company = current.request.<companyField>;

var ritm = new GlideRecord('sc_req_item');

ritm.get(current.sys_id);

ritm.<companyField> = company;

ritm.update();

when task is created you can use this in the advanced script section in Catalog Task activity

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