Custom table - variable formatter - changes not saved

kristenankeny
Tera Guru

Attempting a new thread for this question. We needed to extend the sc_req_item table, which is done and most everything is working as needed. However, we're having issues with the variables not saving changes. The formatter is set up properly and shows the variables for the current required item (custom table name) and their appropriate values. When changes are made from the required item and saved, when the required item refreshes the changes are not reflected/are never saved.

1 ACCEPTED SOLUTION

kristenankeny
Tera Guru

After speaking with ServiceNow, we approached this solution differently. We kept the records on the sc_req_item table, instead of extending it. Then we added a field called "partitions" that has two values, one of which is default (so showing whatever view they have access to) and position_bundle, which triggers a view rule that forces them into the PositionBundle view. On the new record types, we set partition to "position_bundle" so that the view rules run.


View solution in original post

11 REPLIES 11

sachin_namjoshi
Kilo Patron
Kilo Patron

Did you check sc_item_option_mtom table to actually see if the variables are created?


This may be issue for variables not getting saved.



Regards,


Sachin



Hi Sachin,



Yes, I checked the table and there are entries for the extended table records and the original values are displayed in the formatter. The issue is only with the change of the values via the variable formatter not being saved.


I think below should help you to resolve issue.



Create a UI formatter


Name = Task Variable


Formatter = com_glideapp_questionset_default_question_editor and


Table = <<YOUR TABLE NAME >>>



Add this "Task variable" formatter to <<<YOUR TABLE NAME>>> form layout.



Now write a BR on <<<YOUR TABLE NAme>>> table to copy parent table variables



When: on Insert/Update


var variables = new GlideRecord('question_answer');


variables.addQuery('table_name','table_name');// modify according to your table name


variables.addQuery('table_sys_id',current.parent.sys_id);


variables.query();


while(variables.next())


{


var taskVariable = new GlideRecord('question_answer');


taskVariable.initialize();


taskVariable.table_name = current.getTableName();


taskVariable.table_sys_id = current.sys_id;


taskVariable.question = variables.question;


taskVariable.value = variables.value;


taskVariable.insert();


}



Regards,


Sachin


Hi Sachin,



I'm not sure how copying the parent table variables will assist the issue. The variables are already associated with my required item. Also, the parent to my required item is not a requested item, it is a position (which is an extension of the request table), so the position does not have variables associated with it.