I created one String field and given default value. but that value is not reflecting on old records.what do i need to do to populate that string on old records.Is there any property i need to set?or do i need to run schedule job to update all recs.

mayurk
Tera Contributor

Please suggest the solution

4 REPLIES 4

akt_snow
Giga Expert

Hi Mayur,



Update the old records using a Background script.



Thanks,


Avneet


Bhavesh Jain1
Giga Guru

Default value gets updated only for new records. For old records you will need to write a background script.


Make sure you use setworkflow(false) amd autoSysFields(false) in your script.


Subhajit1
Giga Guru

Hi Mayur,


Avneet pointed you in the right direction.


You will have to Query and Update all your records that contain this New table.



You will have to use:-


gr.setForceUpdate(true); // assuming your Glideobject variable is gr


gr.setWorkflow(false);


gr.autoSysFields(false);



Thanks,


Subhajit


harikrish_v
Mega Guru

Hi Mayur,



Goto Scripts Backgroud and execute a code like this:-



var gr=new GlideRecord('<table_name>');


gr.addQuery('<field_name>','!=','<string_value>');


gr.query();


while(gr.next()){


gr.<field_name>='<string_value>';


gr.update();


}


Here I m checking for records that does not have this field equal to the default valur and then updating them with the defqault value.



Hope this helps.



Thanks & Reghards,


Hari