Does GlideRecord or GlideQuery allow access like INSERT INTO ... ON DUPLICATE UPDATE?

David Hubbard
Tera Guru

I am exploring whether Glide APIs support the ability to update columns in multiple rows with different values in one call.  

 

Currently we are doing this in multiple calls and a large update can take many seconds - hence looking to see if there is a way to do this in a single call, which (hopefully) would be considerably faster.

 

I see similar question on SQL usage here and here which suggest the "INSERT INTO table ... ON DUPLICATE UPDATE" to get multiple rows updated at once.  

 

I confess I am not hopeful here - as I understand it ServiceNow uses MariaDB which supports SQL and that supports these SQL statement format, but SN only exposes access for Javascript via the GlideRecord and GlideQuery.  So do they provide such a mechanism?

 

I have looked at "updateMultiple" but I believe that is to update columns in multiple rows with the same value - which isn't my requirement.

 

 

 

1 ACCEPTED SOLUTION

DrewW
Mega Sage
Mega Sage

No the API's the ServiceNow provide do not allow this kind of access/update method.  All you can do is use a While Loop or the updateMultiple method and call it multiple times.

 

You are going to have to build a script to check if each record needs to be inserted or updated and then based on that create or update records.

 

 

View solution in original post

2 REPLIES 2

DrewW
Mega Sage
Mega Sage

No the API's the ServiceNow provide do not allow this kind of access/update method.  All you can do is use a While Loop or the updateMultiple method and call it multiple times.

 

You are going to have to build a script to check if each record needs to be inserted or updated and then based on that create or update records.

 

 

Thanks @DrewW .  That was my expectation - just wondering if I had missed anything, before I embark on major changes