Deleting a table using a fix script

Ali31
Giga Contributor

Hi. 

I have multiple tables that need to be cleaned in my current scope. Unfortunately the application repository does not drop these tables even though they are removed in dev. 

I want to create a fix script that drops the whole table upon upgrade. How do I go about on doing this? I have tried doing a glide record on sys_db_object but that doesn’t delete the table. 

1 ACCEPTED SOLUTION

i think dropTable will also delete scoped app table. anyway did you also try with TableUtils script include ? its ootb script include. 

 

 

var tu = new TableUtils();
tu.dropAndClean('<table name>');

 

 

Doc link for further details. 

 

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...

View solution in original post

3 REPLIES 3

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Did you try:

gs.dropTable('table_name');

Obviously, be really careful with this!

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks @Mark Roethof. This works only from the global scope it seems. Are there any other scoped APIs that drop tables?

i think dropTable will also delete scoped app table. anyway did you also try with TableUtils script include ? its ootb script include. 

 

 

var tu = new TableUtils();
tu.dropAndClean('<table name>');

 

 

Doc link for further details. 

 

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...