Transform Map onBefore Script Skipping Records Due to Business Rule

kanishkamal
Tera Contributor

Hi Community,

I am currently working on an implementation within the HRSD module and facing an issue related to Transform Maps and onBefore Transform Scripts.

 

Requirement

  • I have two custom tables:
    • Table X (target table) – extended from a core HRSD table
    • Table Y (reference/lookup table) – also extended from a core HRSD table
  • During data import, I receive values for two fields (Field A and Field B).
  • The requirement is:
    • If both Field A and Field B contain new values (i.e., the records do not exist in Table Y),
    • Then both values should be inserted as new records into Table Y.

Current Implementation

  • I have implemented this logic using an onBefore Transform Script.
  • The script checks whether the values in Field A and Field B already exist in Table Y and inserts them if they do not.

Data Scenario

  • The source data (Table X) contains repeated values in Field A and Field B (they are not unique).
    • Example values:
      John, John, Smith, Smith, Smith
  • Overall, there are 12 distinct values combined across Field A and Field B.

Issue Observed

  • During transform:

    • The very first record (e.g., “John”) is inserted into Table Y as expected
    • However, all subsequent new values are skipped
    • As a result:
      • Only 1 record gets inserted into Table Y
      • The remaining 11 expected records are not inserted
      • Corresponding fields in Table X appear empty or unpopulated
  • Upon checking the Import Set → Transform History logs, I see messages indicating:

    Record insertion skipped, possibly due to a Business Rule

Concern

  • There are no intentional Business Rules designed to block these inserts.
  • There is no requirement to ignore the entire row just because a lookup value already exists.
  • The skipping behavior appears to affect the entire transform row, not just the lookup insert logic.

Questions

  1. What could cause subsequent records to be skipped during transform even though the source data is valid?
  2. Are there any out-of-the-box HRSD Business Rules or table-level constraints that could silently prevent inserts?
  3. What is the recommended design approach to:
    • Insert missing lookup/reference records
    • Without impacting or skipping the main target record during transform?

Any guidance or best practices for handling this scenario in HRSD would be greatly appreciated.

Thanks in advance for your help.

2 REPLIES 2

palanikumar
Giga Sage

Can you tell me the exact table name you are extending and share the script used in on before script.

Thank you,
Palani

This onBefore Transform Script is configured on the Transform Map of another custom table, which extends the sn_hr_er_interview table

(function runTransformScript(source, map, log, target) {

 

    function recordFactory() {
        return new GlideRecord('x_resource'); // Custom table extends sn_hr_core_profile
    }

 

    function recordExists(recordName) {
        var gr = recordFactory();
        gr.addQuery('name', recordName);
        gr.setLimit(1);
        gr.query();
        return gr.next();
    }

 

    function ensureRecordExists(recordName) {
        if (!recordExists(recordName)) {
            var gr = recordFactory();
            gr.initialize();
            gr.name = recordName;
            gr.insert();
        }
    }

 

    ensureRecordExists(source.u_field_one);
    ensureRecordExists(source.u_field_two);

 

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