Variables Section not showing up on form

kenton3
Kilo Contributor

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

5 REPLIES 5

Kuldeep Kumavat
Mega Guru

Hi Kenton,

Were you able to resolve this issue. I also have a similar issue, where the variables are not marked read-only. g_form.setVariablesReadOnly(true) in a client script does not work. Also, a catalog UI policy on the record producer which sets target variables read-only does not work.

This behavior is observed when variable records are inserted from backend (via script) in the question_answer table. I am still investigating the cause for this.

 

Regards,

Kuldeep