clear fields on multiple records by script

Consiglia
Tera Contributor

Hi all,

I have to clear a lot of records (30k and will increase) every night, only in two fields (email & sso). After that, I have to import this data again (so I have only the active ones).

 

Obviously I can go record by record with GlideRecord, but I was wandering if exists a better way (a sort of deleteMultiple but only on specific fields)

 

I cannot find anything, but maybe I am searching wrong because I think it's a basic need.

1 ACCEPTED SOLUTION

Nicholas_Gann
Mega Guru

You could try using updateMultiple(). See:

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

The docs suggest it should be able to empty out fields by using setValue([field_name], null) unless I'm reading it wrong

 

https://snprotips.com/blog/2016/12/20/pro-tip-use-updatemultiple-for-maximum-efficiency suggests its more performant in comparison to cycling through the GlideRecords individually but I've never used it, which is probably a mistake on my part.

View solution in original post

3 REPLIES 3

Nicholas_Gann
Mega Guru

You could try using updateMultiple(). See:

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

The docs suggest it should be able to empty out fields by using setValue([field_name], null) unless I'm reading it wrong

 

https://snprotips.com/blog/2016/12/20/pro-tip-use-updatemultiple-for-maximum-efficiency suggests its more performant in comparison to cycling through the GlideRecords individually but I've never used it, which is probably a mistake on my part.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Have you considered creating a Scheduled Flow? And reading your description, most likely zero code involved.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

as an "old" SN adopter we have A LOT of scheduled jobs going on everyday, so it's difficult for me change the approach only for the last of the queue.

 

But I will surely watch your suggestion, maybe move the existing to scheduled flow it's painless (or maybe only a little pain 😅)