Need to populate custom table field with RITM number

Sharath807
Tera Contributor

Hi friends, iam working on a task in which i attach an excel sheet containing records in a catalog item , when i sumbit that catalog item ,records from excel gets populated in custom table. This is done by copying attachement from sc_req_item to datasource followed by transform map  its working fine. Now the issue is the custom table contains one field called Ritm number, the field should be populated with the ritm number of reqseted item when ever records is created using the catalog item. How can i achieve this. help me

17 REPLIES 17

HrishabhKumar
Kilo Sage

Hi @Sharath807 ,

To achieve this, you can follow these steps to ensure that the RITM number is populated in your custom table when records are created using the catalog item:

 

  • Modify the Transform Map: Update the transform map to include a field mapping for the RITM number.
  • Script in the Transform Map: Use a script to set the RITM number on each record being imported.

 

I've tried to provide you the steps as well:

 

Step 1: Add the RITM Number to the Data Source

Ensure that the RITM number is included in the data source so that it can be mapped in the transform map.

 

Step 2: Update the Transform Map

Open Transform Map: Go to System Import Sets > Administration > Transform Maps.

Select Your Transform Map: Choose the transform map you're using to import data from the Excel sheet.

 

Step 3: Add a Script to Transform Map

  1. Transform Map Field Mapping: Ensure you have a field in your custom table to store the RITM number (e.g., u_ritm_number).
  2. Field Mapping: Create a field mapping for u_ritm_number.
  3. Scripted Field Mapping: Add a scripted field mapping to populate the RITM number:

 

Click on "Mapping Assist" or "Script" for the field u_ritm_number.

Use the following script to set the RITM number from the current import set record:

 

 

(function transformRow(source, target, map, log, isUpdate) {

    // Assuming the RITM number is stored in a variable in your data source

    var ritmNumber = source.u_ritm_number; // Adjust this line based on your data source

    

    // Set the RITM number on the target record

    target.u_ritm_number = ritmNumber;

})(source, target, map, log, action);

 

 

 

Step 4: Ensure RITM Number is Available in Data Source

Make sure the RITM number is being passed correctly from the catalog item to the data source. You might need to set the RITM number when copying the attachment from sc_req_item to the data source.

 

 

Thanks,

Hope this helps.

If my response proves helpful please mark it helpful and accept it as solution to close this thread.

Sharath807
Tera Contributor

@HrishabhKumar Hi, i didnt get this line "Ensure that the RITM number is included in the data source so that it can be mapped in the transform map'".In excel sheet there is no column RITM.

saicharan3
Tera Expert

Hi @Sharath807 

 

As HrishabhKumar is syaing that in the excel sheet you have be one column name as RITM Number then above script will work as expected

Sharath807
Tera Contributor

@saicharan3 @HrishabhKumar  Actually i need to populate the ritm number dynamically. If there is 10 records in excel. That 10 records will be created in custom table once the catalog is submitted. Those 10 records contains reference field Ritm (sc_req_item). That field should be dynamically filled by ritm number ( the one the excel pass from catalog item to reqitem)