How to populate reference field in target table from parent record during Transform Map (Scoped App)

Barath P
Kilo Sage

Hi everyone,

I’m working on a requirement in a scoped application and need some guidance.

Scenario:

  • I have a custom Request table where users create a record and attach an Excel file.

  • Upon saving the record, a Data Source is triggered, which loads the Excel data into an Import Set and runs a Transform Map.

  • The Transform Map creates records in a target table.

Requirement:
In the target table, I have a reference field called request_from (which references the parent Request record).
I need this field to be automatically populated with the sys_id of the Request record from which the Excel file was uploaded.

Challenge:

  • The value is not present in the Excel file, so I cannot map it directly in the Transform Map.

  • This should only populate when the user uploads the attachment and triggers the import.

Question:
What is the best practice to pass the parent record (Request) sys_id into the Transform Map so that I can populate the request_from reference field in the target table?

Any suggestions or examples (especially for scoped applications) would be greatly appreciated.

Thanks in advance!

1 REPLY 1

ayushraj7012933
Mega Guru

Hi,

This is a common use case with Import Sets. Since the Request sys_id is not part of the Excel file, the best practice is to pass it through the Import Set instead of trying to map it from the file.

Recommended Approach

  1. Add a field on Import Set table
    Create a custom field (e.g., u_request) on the Import Set (sys_import_set) table to store the parent Request reference.

  2. Set Request sys_id during import trigger
    When the Data Source is triggered from your Request record (via Flow/Script/BR), populate this field:

    script:
    importSet.u_request = current.sys_id;
     
  3. Use Transform Map Script
    In your Transform Map → onBefore script, set:

    script:
    target.request_from = source.sys_import_set.u_request;