Deleted filed still shows up in the List layout and form layout but not in table ?

rajendravunnam
Kilo Expert

Hello,

I have a   string field 'platform'(u_platform) , i tried to convert it into Reference. I have deleted the field and created a new one with the same name 'Platform' (u_platform) but as a reference field. All this is captured in a single update set. When this update set is moved to Dev from Beta environment, there was an error   while committing the update set:

Error

sys_dictionary_change_request_u_platform

Type change not allowed. Invalid type conversion for field 'Platform' on table 'Change Request'. Cannot convert from 'String' to 'Reference'. There exists data records (252) that are not a Sys ID.

so, in   my Beta instance i have deleted the Reference field and added it back as a String and moved it to dev (the update set which has String configuration captured). Now dev looked good. But again i have deleted this field in beta and moved the update set to Dev. Unfortunately the field was still showing up as 'u_platform' on the form and list layout but i can't see it in the table.   When i tried to configure dictionary on this field, it is giving me 'no record found'.There were already some records for which this field is populated in Dev.   I am not sure how to fix this and what problems would arise when i move this change to TEST and beyond. Any help is appreciated.

1 ACCEPTED SOLUTION

veena_kvkk88
Mega Guru

Hi Rajendra!



I've faced this way too many times! If you check the 'sys_storage_alias' table, and search for the field name in the element column, I'm pretty sure you'll find it which is the reason you see it in the layouts, but not in the table.



When we delete a field, the storage alias is not being deleted sometimes. Once that's deleted too, it shouldn't show up anymore. However, even admins cannot delete stuff from that table and its not advices to change the acls. You need to create a HI ticket and ask HI team to delete it for you.


View solution in original post

13 REPLIES 13

Daniel Gens
Tera Contributor

For future readers:

 

Following Veena's suggestion, I took at look at 'sys_storage_alias' table and found me "ghost field" in there. Moreover, I was able to delete a record in that table without contacting HI.

I ran the following background script to delete the record:

var sys_id = "e7e80a80dbb35f00a41efb0e0f96199b"; // substitute your sys id
var gr = new GlideRecord('sys_storage_alias');
gr.get(sys_id);
gs.info(' Table Name: ' + gr.table_name + ' Column Name: ' + gr.element_name);
gr.setWorkflow(false);
var flag = gr.deleteRecord();
gs.info(flag); // will return true if record is deleted successfully

DNC
Tera Contributor

Hi Daniel

 

I have used the same script and executed it in the background script.

The record is deleted from the 'sys_storage_alias' but, still, the field is available in the form.

 

Tried to hide via UI Policies, but no luck

Daniel Gens
Tera Contributor

Hi Nagarjuna,

 

I've been using the following Fix Script to fully and cleanly delete table columns as it requires not only clearing sys_storage_alias, but also sys_dictionary and sys_documentation:

 

Name: Delete table column

Active: true

Unloadable: false

Run once: false

Flush cache: false

Before: false

Description: Deleting a column doesn't cleanly remove all references to it. Use this script to cleanly delete table columns.

Script:

// Replace with your table name
var table = 'incident';

// Replace with your column name
var column = 'u_metric';

// Running and checking success
gs.info("cleanDict successful? " + cleanDict(table, column));
gs.info("cleanAlias successful? " + cleanAlias(table, column));
gs.info("cleanDoc successful? " + cleanDoc(table, column));


function cleanDict(table, column) {
	var gr = new GlideRecord('sys_dictionary');
	gr.addQuery('name', table);
	gr.addQuery('element', column);
	gr.query();
	while (gr.next()){
		gr.setWorkflow(false);
		return gr.deleteRecord();
	}
}

function cleanAlias(table, column) {
	var gr = new GlideRecord('sys_storage_alias');
	gr.addQuery('table_name', table);
	gr.addQuery('element_name', 'CONTAINS', column);
	gr.query();
	while (gr.next()){
		gs.info(gr.getDisplayValue());
		gs.info(' Table Name: ' + gr.table_name + ' Column Name: ' + gr.element_name);
		gr.setWorkflow(false);
		return gr.deleteRecord();
	}
}

function cleanDoc(table, column) {
	var gr = new GlideRecord('sys_documentation');
	gr.addQuery('name', table);
	gr.addQuery('element', 'CONTAINS', column);
	gr.query();
	while (gr.next()){
		gs.info(gr.getDisplayValue());
		gs.info(' Table Name: ' + gr.name + ' Column Name: ' + gr.element + ' Column Label: ' + gr.label );
		gr.setWorkflow(false);
		return gr.deleteRecord();
	}
}

 

After it's all set up, you can Run Fix Script with the UI action on the Fix Script form. Note that if you've already delete your column from sys_storage_alias, the deletion will appear not successful because the record is already gone.

RiteshSwarnakar
Giga Guru

Background Script to find out those which are not sys_id :

var ga = new GlideAggregate('table_name');           
var c = 0;
ga.groupBy('field_name');
ga.query();
while (ga.next()) {
if (ga.field_name.toString().length!=32){
gs.print(ga.field_name);
c+=1;
}}
gs.print(c);