Variable in variable set duplicates into variable editor. Service Portal

C_sar1
Giga Contributor

Hi,
I'm facing an issue concerning our record producer development. 

I have multiples record producers with a lot of variables set. Everything works as expected except one thing :

Values from form on portal are duplicated inside the 'Variable Editor' of my current table. I know I can't map a variable which is inside a variable set. But I don't want them to be deplicated inside my variable editor.

Any ideas ? Already tried something like this : current.u_version = producer.u_version;

u_version is in a variable set. It ends up in both variable editor and the current object. Which seems wrong ...

Thanks.

1 ACCEPTED SOLUTION

Hello Rolf,

Sorry I was in holidays.

I ended up writing a script to hide existing variables in form.

1 -> Create variables that have the same name of those in the target table.

2 -> Write a UI Policie on the target table form.
        When to apply : On Load with no conditions


Script :

// Function to hide variables when they already exist in the table
function onCondition() {
// Loop on form elements
for (var i=0; i< g_form.elements.length; i++) {
      // Check elements off change_request
      if(g_form.elements[i].tableName == "change_request"){
            // Hide all existing variables that have the same name of change_request column
	    g_form.setDisplay('variables.'+g_form.elements[i].fieldName,false);
      }
}
}

View solution in original post

3 REPLIES 3

Rolf Nyhus
Tera Guru

Hi César,

Did you ever find a solution for this? We seem to have the same issue, but in our case it also applies to record producers with regular variables.

 

Regards,

Rolf

Hello Rolf,

Sorry I was in holidays.

I ended up writing a script to hide existing variables in form.

1 -> Create variables that have the same name of those in the target table.

2 -> Write a UI Policie on the target table form.
        When to apply : On Load with no conditions


Script :

// Function to hide variables when they already exist in the table
function onCondition() {
// Loop on form elements
for (var i=0; i< g_form.elements.length; i++) {
      // Check elements off change_request
      if(g_form.elements[i].tableName == "change_request"){
            // Hide all existing variables that have the same name of change_request column
	    g_form.setDisplay('variables.'+g_form.elements[i].fieldName,false);
      }
}
}

Hi César,

Now it was my turn to be on holiday. Thanks for replying. I will keep your solution in memory, but for now we have opted to revert our sc_cat_item widget to OOB as we too started seing the same issue as Suzanne (https://community.servicenow.com/community?id=community_question&sys_id=89602b9bdb19941023f4a345ca96...) did after moving to New York release. Hopefully this fixes our issue, and could potentially work for you as well. Since we had ever so slightly modfied our widget, we had missed some updates.

Rolf