Variables Section not showing up on form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2019 12:18 PM
I have a record producer that is creating records on the sn_sm_marketing_request table. The users wanted the one form to be able to create multiple tickets so I have it cancel the generated record and manually create them. I also manually create the variables and here is the code to do that.
var childTable = 'sn_sm_marketing_request';
function createChild(){
var child = new GlideRecord(childTable); //set the table for the child record.
child.initialize();
child.parent = producer.project;
var marketing_project = new GlideRecord('u_sn_sm_marketing_project');
if(marketing_project.get(producer.project)){
child.caller = marketing_project.caller;
child.u_initiating_dept = marketing_project.u_initiating_dept;
}
child.description = 'Delivery for marketing project';
var childTask = child.insert();
return childTask;
}
function insertVar(variablesSys_id, childTask){
var i;
for (i = 0; i < variablesSys_id.length; i += 2){
var variable = new GlideRecord('question_answer');
variable.initialize();
variable.table_name = childTable;
variable.table_sys_id = childTask;
variable.value = variablesSys_id[i + 1];
variable.question = variablesSys_id[i];
variable.order = i;
variable.insert();
}
}
if(producer.web == 'true'){
var childTask = createChild();
vID = producer.specific_requirements.getED().toString().substring(2); //Gets sys_id of variable
//Insert variable into Question Answer Table.
var variable = new GlideRecord('question_answer');
variable.initialize();
variable.table_name = childTable;
variable.table_sys_id = childTask;
variable.value = producer.specific_requirements;
variable.question = vID;
variable.insert();
insertVar(variablesSys_id, childTask);
var child = new GlideRecord(childTable);
child.get('sys_id',childTask);
child.short_description = producer.web_short_description;
child.assignment_group = 'aa9f27f8137bd2004e02b027d144b05a'; // web team sys_id
child.template = 'f487063a1352eb0000263482e144b089';
child.update();
}
Now in the form there are several deliverables that the user can choose to create. The above snippet is for the web deliverable. This will create a record on the 'sn_sm_marketing_request' table. The insertVar inserts variables into the 'question_answer' table. So when you query the generated record and then look at the variables like so: 'gr.variables.specific_requirements' it will show you the value of the variable. However it will not show you the gray variable section on the record even though the variable editor formatter is there.
Any guidance on how to get it to show up will be helpful.
Thanks,
Kenton
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2019 07:32 PM
Hi Kenton,
Are you saying the variables are not shown on the form under variables section?
Did you add the variable editor on the form by configuring the form layout?
Are you saying the variables are not set to readonly on the form?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2019 05:46 AM
The variables section that looks like the below picture is not showing up.
On the form layout I have the variable editor on the form like so:
However no variables show up:
I can query the record with
var test = new GlideRecord('sn_sm_marketing_request');
test.get('fe2033af13a14c905e7d7d346144b0d9');
test.variables.supporting_graphics
and this will display the value that the variable holds so I know that it is getting assigned properly just the variables section doesn't show up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2019 08:48 PM
Hi,
check below link
https://hi.service-now.com/kb_view.do?sysparm_article=KB0538897
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2019 05:15 AM
Thanks for you reply but this also did not work. The table already has a variable row and I tried the custom formatter to no avail.