Create system property for mapping and use it for dynamic value

Priyanka Chaud1
Tera Contributor

I want to use a mapping kind of thing 

and store this in system property and use it  in my script include to make tablename,parentfield and column name dynamic how can i achieve this @suvro 

 

1 ACCEPTED SOLUTION

suvro
Mega Sage
Mega Sage

Just create a property with below values

{ "task" :{"refField": "parent", "qField" : "number" }, "incident" :{"refField": "parent_incident", "qField" : "number" }, "sys_user" :{"refField": "manager", "qField" : "name" }, "problem" :{"refField": "duplicate_of", "qField" : "number" }}

 

call that property

var tableName = gs.getProperty('property name'); //another property which stores tablename

var propV = gs.getProperty('property_name');

var propObj = JSON.parse(propV);

Now you can use it : 

propObj[tableName ].refField and propObj[tableName ].qField

View solution in original post

15 REPLIES 15

suvro
Mega Sage
Mega Sage

Just create a property with below values

{ "task" :{"refField": "parent", "qField" : "number" }, "incident" :{"refField": "parent_incident", "qField" : "number" }, "sys_user" :{"refField": "manager", "qField" : "name" }, "problem" :{"refField": "duplicate_of", "qField" : "number" }}

 

call that property

var tableName = gs.getProperty('property name'); //another property which stores tablename

var propV = gs.getProperty('property_name');

var propObj = JSON.parse(propV);

Now you can use it : 

propObj[tableName ].refField and propObj[tableName ].qField

@suvro i have to use 

var tableName = gs.getProperty('property name'); //another property which stores tablename

var propV = gs.getProperty('property_name');

var propObj = JSON.parse(propV);

in every function of script include

Define the variables in the  initialize function of the script include like below then it will be available for all functions of the script include. You will not have to define those in every function

this.tableName = 

this.propV =

 

initialize: function() {
      this.tableName = gs.getProperty('x_cyso_org_hierarc.dropdown_value'); 
       this.propV = gs.getProperty('x_cyso_org_hierarc.parentref _fields');
       var propObj = JSON.parse(propV);
    },

is this the way it would be initialiaze in one function @suvro beacuse i used it so got errors in logs