Update all records. Can you update a field to empty?

dartx21
Kilo Contributor

Hi All,

I am trying to update a reference field to empty for all records.

I tried filtering and update all on those records to make the reference field empty.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi Chris,



Have you tried this



gr.assigned_to = "";



Re: Updating reference fields with 'NULL'



Regards,


Harshvardhan


View solution in original post

9 REPLIES 9

dartx21
Kilo Contributor

I was hoping to just keep it simple by right clicking and updating all/selected records to make a reference field null.



I know this can be done through gliderecord and background script. If this cannot done through the right click and update script I will mark the glide script answer correct.



Thanks


Chris


Hi Chris,



Main problem with Update All is that you need to put something in the field where you want to change the value. Leaving it untouched will not update the value.


In case of reference fields, you can't just add a space I assume as it's not going to be empty anymore.



Regards,


dartx21
Kilo Contributor

I was hoping there was a easier solution.



Thanks Sergiu


p_espinar
Kilo Guru

I have tried with NULL and it works.

Un saludo,

Pablo Espinar

To add to this, NULL needs to be a string like so:

    var list = new GlideRecord("incident");
    list.addEncodedQuery("cmdb_ci=some_sys_id");
    list.cmdb_ci = 'NULL';
    list.updateMultiple();

 

Thanks for the help 6 years in the future 🙂