How to delete custom column using fix script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 11:31 AM
Is there a way to script a column's deletion so that everything is performed as though the column was deleted using the GUI?
The London release has introduced a "Parent Contract" field to the ast_contract which has resulted in our custom "Parent Contract" field added in early 2017 to be redundant. I am working on a fix script to copy the data from the custom field into the OOB field, and would like to be able to delete the custom column as the final step in the script.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 02:24 PM
This change is to be migrated via an update set across multiple instances, and I desire to implement the change as a 2 step process; commit the update set and run the fix script. Including the deletion into a script will allow for implementation of tested, repeatable results limiting the potential for user error during an extra manual step to be performed following execution of a script.
The following tasks are intended to be performed by the fix script.
1) Copy the data from the custom field into the new OOB field.
2) Adjust report definitions referencing the custom field to use the new OOB field.
3) Drop the custom field from the database

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 02:34 PM
Please use below script to delete column
var col = new GlideRecord('sys_dictionary');
col.addEncodedQuery('name=abc');// update your query
col.query();
while(col.next()){
col.deleteRecord();
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 02:40 PM
Will that perform a cascade delete to related indices, form/list layouts, labels, etc for the field being deleted?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2019 02:48 PM
Yes, it will do cascade delete for objects you mentioned.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 02:56 PM
I have just tested deleting the column from sys_dictionary by deleting the record using the script, but it did not cascade delete records from sys_ui_element or sys_security_acl tables as expected.
If it matters, I am needing this functionality in the London release.