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

How can I retrieve this sys_id when the transform map is triggered automatically?

PavanKumar8
Tera Contributor

Hi 

I am automating the Excel upload process that runs when my custom request record gets approved. The data is being imported successfully, but I also want to store the request record’s sysid or number in the target table to identify which request triggered the import.

Could anyone please help me understand how to achieve this?

Thanks in advance

5 REPLIES 5

Rafael Batistot
Kilo Patron

Hi @PavanKumar8 

 

When inserting each record from the Excel import, set the request’s sys_id (or number) into a field on the target table.

 

Example with onBefore script:


target.u_request = current.sys_id;

kaushal_snow
Mega Sage

@PavanKumar8 ,

 

You can capture the triggering request record’s sys_id into the import flow by adding a field in your import set (e.g. u_request_sys_id) and setting it before transform, then in your onBeforeTransform or onStart script of the Transform Map do something like...

 

(function transformRow(source, target, map, log, isUpdate) {
    if (source.u_request_sys_id) {
        target.u_request = source.u_request_sys_id; 
    }
})(source, target, map, log, isUpdate);

 

If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

@Ankur Bawiskar  @kaushal_snow 
I am triggering my transform map through a Business Rule when my custom request record gets approved.
I referred to the link below to automate the data upload.
As mentioned earlier, I want to use one field from my request record and, while inserting new records during the import, combine those values and insert them into my third table.
Could you please guide me on how to get the table sysid from the data source when the transform map is triggered?



Bhuvan
Mega Patron

@PavanKumar8 

 

See if you can make the request number as a variable that can be accessed in transform script. If that is not possible, capture this information as part of data source used for transformation and use the mapping as part of transform script or field mapping.

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan