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

Help with Transform Map script

joelw
Tera Contributor

Hi All,

I have a requirement to import a csv daily in to a case management solution and I'm a little stuck on the transform map script.

I have the one data source and three transform maps.   The first transform map imports a 'customer' records, the second 'account' records and the third 'case' detail which includes the customer number (it's a reference field in the target table) which was loaded on the first transform.

The onBefore transform map script is below - where I want to check the 'case' table to see if there is an 'active' case and the source customer number = the target customer number in the case record.   And if so, don't insert.     They currently all go and insert so obviously I missing something in my script - any assistance would be greatly appreciated.

Cheers,

Joel

//Check to see if record exists in CASE table

//Compare CUSTOMER NUMBER and ACTIVE flag

var customer = source.u_customer_number;

var rgcase = new GlideRecord('x_taipl_case_mgmt');

rgcase.addQuery('active', true);

rgcase.addQuery('customer.customer_number', customer);

rgcase.query();

//IF RECORD ALREADY EXISTS SKIP THE RECORD AND GO TO THE NEXT

    if(rgcase.next()){

            ignore = true;

    }

7 REPLIES 7

joelw
Tera Contributor

Thanks Geoffrey/Matthew, appreciate the feedback.



Will add some debug lines and see what it brings first and go from there.



Good to know the gs.debug for scoped apps - as I did start putting in the gs.log!



Keep you updated.


joelw
Tera Contributor

So... interesting results... added the gs.debug lines in and got nothing in the logs.



Ran the script as a 'background' and explicitly gave it a customer number instead of the 'source.u_customer_number' and it specified it 'found' records.



I then used that exact code in the transform map script and it still went and inserted all again. So it is almost like the script isn't running.



Could it be the scoped app getting in the way?   Although the import set table and transform map are all under the app scope so I wouldn't have thought so.



I'll try and get the debug working - just thought to give an update.


Mwatkins
ServiceNow Employee
ServiceNow Employee

Was there anything that came out in the logs at all? What's the value of the scope_name.logging.verbosity property? For gs.debug() to work the level has to be "debug".