How to delete temp table

rako
Kilo Expert

I attempted to extend Task on an existing custom table, as seen here - https://community.servicenow.com/message/727348#727348

The table successfully generated a new temp table z_x_inst_app_tablename, but due to a naming conflict on one of the fields, it failed to merge z_x_inst_app_tablename back into

x_inst_app_tablename. I fixed the naming conflict, but now I have a temp table that I cannot seem to get rid of. How do I delete it?

The temp table extends Task, so Deleting All Records from the System Definitions -> Tables fails due to the global scope of Task.

I cannot re-parent the temp table to remove Task, b/c it is not in customer scope (z_ prefix instead of x_)

I cannot re-parent the original, b/c the temp table already exists and is not replicating.

I also tried deleting the Dictionary entry of the temp table, which simply renamed the table label to Task and left it in place.

Any help would be appreciated.

1 ACCEPTED SOLUTION

EduardoMorales
Tera Expert

Hi rako



One way to achieve this is using the TableUtils Server Side Legacy API Methods. https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=c_TableUtilsAPI



"Please be extremely cautious when droping a table and its references". (I hope you previously have saved your work in update sets, and get a backup from all data and related work on the table.)



If you are complete sure the table must be gone, let's proceed.



1) From the Legacy API chose the method which best works for you. Check consciously to make the best choice for your needs. For Example: dropAndClean


2) Identify the entries related to your table on the System Dictionary. (System Definition -> Dictionary). Filter by your table name. [Verification step]


3) Go to System Definition ->Scripts - Background (Be extremely cautious at running script from here, adhere to Servicenow recommendations Scripts - Background)


      And create a function to run the chosen method from TableUtils Legacy API, for example:



testDropTables();



function testDropTables(){


        var table = new global.TableUtils("z_x_yourCompanyCode_yourApp_temp_table");//To get proper output with tableExist method


                table.dropAndClean("z_x_yourCompanyCode_yourApp_temp_table");


        gs.print("+++ Does 'my_table' exist? " + table.tableExists());


        gs.print("+++ Script Test Finished...");


}


        4) Once the script is in place, please chose proper scope to run the script, in this case global   as TableUtils belong to that scope.


                  2017-04-11 14_08_31-ServiceNow.png


With all set just run the script, you will get a log output similar to:



TABLE DROP: ed morales dropped table z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing gauges for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing forms for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing styles for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing forms sections for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing lists for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing related lists for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing references to z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing dictionary entries for z_x_yourCompanyCode_yourApp_temp_table


*** Script: removing table-specific ACL entries for z_x_yourCompanyCode_yourApp_temp_table


Background message, type:info, message: Table deleted


*** Script: +++ Does 'my_table' exist? false


*** Script: +++ Script Test Finished...



Finally refresh the filter created on step 2), you will notice the records related to the table have been cleared.



I hope this helps



Eduardo Morales S.


Servicenow Developer and Consultant


View solution in original post

9 REPLIES 9

Rasith1
Tera Expert

Hi Nick,



To delete your temporary table, go to your dictionary and click search Collection Type of your table and click DELETE TABLE. Find the below screenshot.



find_real_file.png



Please try and let me know the outcome.


Hi Abdul,



Thank you for the response. Unfortunately I do not have access to a Delete Table button. I am on Istanbul. Is this a version issue or permissions?


change your application scope. bcz you are not in correct application scope . that's why you are not able to see delete button.


Harsh Vardhan
Giga Patron

Hi



have you tried delete your table from your application scope?



Thanks,


Harshvardhan