Create table using a script in a scoped application

KJM1
Kilo Explorer

I have a bunch of custom columns added to the sn_si_incident table.  I would like to remove them from sn_si_incident and place them in a table that extends sn_si_incident (leaving the base table as OOB).

Instead of manually creating each field, there are a lot of them.  I would like to create a script to create the extended table and add the custom fields.  Saving me a lot of time and possible typing mistakes.

Every article i see uses Packages.java.util.HashMap() and new GlideTableCreator(table_name , table_name).  Neither can be used in a scoped application.  Is there a way to do this in a scoped application?

Any assistance would be greatly appreciated.

1 ACCEPTED SOLUTION

See below, tested = works.

1) create Script Include in global
2) create Fix Script in your scoped app + execute Fix Script
3) see table created (in my example in HR Core scope)

find_real_file.png

find_real_file.png

find_real_file.png

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

Kind regards,
Mark

---

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

View solution in original post

12 REPLIES 12

See below, tested = works.

1) create Script Include in global
2) create Fix Script in your scoped app + execute Fix Script
3) see table created (in my example in HR Core scope)

find_real_file.png

find_real_file.png

find_real_file.png

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

Kind regards,
Mark

---

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

That worked, I didn't think through the solution you sent previously.  Makes sense once I saw your code.

Thank you, I have marked as correct answer.

Also be aware of the number of multi line fields. ServiceNow advice is not to have more then 10 or 12 (I have to look it up on the docs). Obviously this is on the save side, you could actually have a bit more.
This is, the number of string fields with 255+ max length on your custom table + the ones on the table you are extending from.

Mentioning this, because this could cause database issues.

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

Kind regards,
Mark

---

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