Changing Variable Set type from Single row to Multi row

Martin Timko
Giga Contributor

Hello,

 

I have few Variable Sets already created with multiple variables and I realized I need to change the type of theseVariable Sets from Single row to Multi row. Do you think guys that it's safe to do that via background script? Because the Type field is grayed out on the Variable Set form. That means ServiceNow is trying to avoid such change.

Variables in those Variable Sets are type of Date/Time, Yes/No, Select Box, Reference, Single Line Text. There are few UI Policies or Client Scripts for these Variable Sets. I assume the type one_to_one is subset of one_to_many so it should be safe but I am not 100% sure. What is your opinion?

Thanks!


This code will change the type:

var rec = new GlideRecord('item_option_new_set') ;
rec.addQuery('sys_id',"12a345b678c9012d3456e78901f23");
rec.query();


while(rec.next()) {
    rec.type = "one_to_many";
    rec.update();
}

1 ACCEPTED SOLUTION

Rustam2
Giga Expert

I had similar requirement, but I pursued a safer approach.

1. Created a new Multi Row variable set.

2. Went to variables list, filtered on current variable set, mass list edited and changed to new Multi Row Variable set.

 

Basically migrated variables to new variable set, and that is possible OOB.

 

I would be aware of following restrictions though:

You cannot include the following variable types in a multi-row variable set:

  • Break
  • Container End
  • Container Start
  • Container Split
  • HTML
  • Label
  • List Collector
  • Macro
  • Macro with label
  • UI Page
Note:
  • The Map to field functionality is not supported for variables used in a multi-row variable set.
  • Cascading functionality for variables in an order guide is not supported for a multi-row variable set.
  • A multi-row variable set is not displayed when added within a container.
  • A multi-row variable set is supported in the variable summarizer only in Service Portal.
  • You cannot add variables with read roles in a multi-row variable set.
  • When you clone a request that contains a multi-row variable set, the information that is specified in the multi-row variable set is available in all cloned requests. All UI policies and client scripts on the multi-row variable set are also cloned.
  • Set a limit to the number of rows that you can add to a multi-row variable set by using the max_rows attribute in the Variable Set attributes field.

Referencehttps://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-manage...

View solution in original post

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

It's not best practice to change data type in existing implementation.

This is because these variables may have many references e.g reports, client scripts, script includes, UI policies, workflows, flows etc and all these objects may break.

Instead, you should create new variables and run script to copy data from old to new variables.

After data copy is done, you will have to update code which contains old variable references.

Last step will be to make old variables inactive.

 

Regards,

Sachin

Rustam2
Giga Expert

I had similar requirement, but I pursued a safer approach.

1. Created a new Multi Row variable set.

2. Went to variables list, filtered on current variable set, mass list edited and changed to new Multi Row Variable set.

 

Basically migrated variables to new variable set, and that is possible OOB.

 

I would be aware of following restrictions though:

You cannot include the following variable types in a multi-row variable set:

  • Break
  • Container End
  • Container Start
  • Container Split
  • HTML
  • Label
  • List Collector
  • Macro
  • Macro with label
  • UI Page
Note:
  • The Map to field functionality is not supported for variables used in a multi-row variable set.
  • Cascading functionality for variables in an order guide is not supported for a multi-row variable set.
  • A multi-row variable set is not displayed when added within a container.
  • A multi-row variable set is supported in the variable summarizer only in Service Portal.
  • You cannot add variables with read roles in a multi-row variable set.
  • When you clone a request that contains a multi-row variable set, the information that is specified in the multi-row variable set is available in all cloned requests. All UI policies and client scripts on the multi-row variable set are also cloned.
  • Set a limit to the number of rows that you can add to a multi-row variable set by using the max_rows attribute in the Variable Set attributes field.

Referencehttps://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-manage...