The CreatorCon Call for Content is officially open! Get started here.

Transform Map script to create multiple system properties

Khalnayak
Kilo Sage

Hi All,

I am working on bulk importing 50 record producers into ServiceNow.

The only issue I have is the script. I need to add script for all record producers which I have.

The only thing that changes on the script for each Record Producer is the assignment group, as there will be specific group for each record producer.

I cannot use the sys id directly in the script and have to use gs.getproperty().

So I need help in creating a transform map script which looks at the group column in my sheet and for each record producer, it:

1. fetches the sys id of the group

2. Creates a system property with the group name and adds sys id to the value

3. Populates the script and adds the current.assignment_group = gs.getProperty(<sys id of property>);

Thanks.

1 ACCEPTED SOLUTION

Oh I didn't know that field existed, great find.

In that case, you can just push the group into that field, and use the following in the script:

current.setValue('assignment_group' , cat_item.group);

View solution in original post

6 REPLIES 6

Have you used a html field rather than a multi-line field?

Sourabh26
Giga Guru

Hi,

 

For what i understood, you have an excel with column as "group" which stores the sys ids of the group. An need to store this as the property.

You can achieve this as the below logic.

 

//getting the sys id of the group from excel

var grpID = source.group; //column_name as per the excel

//Property Table
var gr = new GlideRecord('sys_properties');
if(gr.get('value',grpID)){ //checking if there is alredy any existing property 
  return;
}
else {
  var counter = 1;
  var propName = 'Group_Name';
  var newName = propName + counter;
  if(!(gr.get('name',grpID))){ //checking if there is any property with same name
    createProperty(newName,grpID);
  }
  else {
  //if there is property with same name then
  counter++;
  newName = propName + counter;
  createProperty(newName,grpID);
  }
}
function createProperty(newName,grpID){
//create new property
    gr.name = newName;
    gr.value = grpID;
    gr.insert();
}

 

Mark this as Helpful in case this helps you in anyways.

 

Regards,

Sourabh