How to create a reference field when using GlideColumnAttributes API?

Dave Oshinsky
Tera Expert

This question has been asked previously, with no satisfactory solution that I've seen so far.

https://www.servicenow.com/community/developer-forum/how-to-create-a-reference-field-when-using-glid...

 

I would like to re-ask the question, with the following added detail.  GlideColumnAttributes API (which is undocumented) does have a setReferenceTable() method.  Calling it (e.g., setReferenceTable("task") to extend "task") yields this exception in a "Fix Script":

JavaException: java.lang.SecurityException: Illegal access to method setReferenceTable(string) in class com.glide.db.impex.ColumnAttributes

 

The setReferenceTable() method is there, but a "Fix Script" cannot successfully call it. How do I create a table like "incidentClone" that extends "task" (like "incident" does) in a "Fix Script"?

1 ACCEPTED SOLUTION

Adding code to modify sys_dictionary after table creation, to reflect the reference info. Modifying "reference" to the parent table, and "reference_floats" to "true" seems to yield a table schema that appears correct. This is similar to the approach detailed here:

https://www.servicenow.com/community/developer-forum/how-can-i-set-max-length-and-reference-value-fo...

 

I'm still not completely sure that this will yield table semantics exactly equivalent to a table with reference columns that have not been hacked this way. I'm also not sure whether this will work in versions other than Utah.

View solution in original post

2 REPLIES 2

Dave Oshinsky
Tera Expert

To correct one error in the original post: I wish for the field to refer to "task", not extend it. In other words, it's a field that's a reference, and the reference is to "task" in the example.

Adding code to modify sys_dictionary after table creation, to reflect the reference info. Modifying "reference" to the parent table, and "reference_floats" to "true" seems to yield a table schema that appears correct. This is similar to the approach detailed here:

https://www.servicenow.com/community/developer-forum/how-can-i-set-max-length-and-reference-value-fo...

 

I'm still not completely sure that this will yield table semantics exactly equivalent to a table with reference columns that have not been hacked this way. I'm also not sure whether this will work in versions other than Utah.