Need to create new field with default value

navdeep_singh
Giga Guru

I want to create a new field (integer) with a value"0" on Incident table.   I want this value to be applied on new as well as existing records.

Will the "Default Value" work? if not please suggest any other option.

Thank you,

Navdeep

1 ACCEPTED SOLUTION

And they weren't updated:


find_real_file.png



Yes, we did it differently.



I went through the dictionary



1. went to System Definition -> Dictionary. Clicked on new


2. Choose the incident table, Integer type, and added 0 as default value:


find_real_file.png


3. Clicked on Submit


4. Run the script to confirm:


find_real_file.png


find_real_file.png



Telmo


View solution in original post

14 REPLIES 14

You can do it like Chuck said, with a background script:



var inc = new GlideRecord('incident');


inc.query();



while (inc.next()) {


        inc.setWorkflow(false);


        inc.autoSysFields(false);


        inc.u_count_field = 0; // Change to YOUR field name


        inc.update();


}




Telmo


Hi Telmo,



Thank you for the information.


If I delete the old column and create a new one with same name using Dictionary as you mentioned, will it work ?


I tried to create new application by deleting old one with same name, but not worked because of same name.




Thanks,


Navdeep


Hi Navdeep,



Maybe again some differences on how you do it.



I deleted my field through the Dictionary, and created a new one also from the Dictionary with the same name and even a different type, and I was able to.




Regards,


Telmo


Interesting that doing the value from the dictionary would differ from doing it from the configure table. Thanks for sharing!


Hi Chuck,



Thanks for this Information.



Regards,


Navdeep