PARSE INFO

Dallas2
Tera Expert

Hello can anyone assist on script, trying to parse MSSQL15.MSSQLSERVER to be Put in table cmdb_ci_db_mssql_instance on instance_name field. this is coming from running process key parameters (running_process_key_parameters) field. I will be using a business rule, but the string below will not always be the same, the running process key parameters field will have different data, so will need to call the running process key parameters, parse and in put in the instance name field.. 

 

from this "E:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\sqlservr.exe"-sMSSQLSERVER  

 

Thank you

 

 

 

 

16 REPLIES 16

Hi @Dallas2 

 

You can try Before/After insert/update Business rule on "cmdb_ci_db_mssql_instance" table as per your need :

 

/*get the value from field*/

var param = current.getValue('running_process_key_parameters');

var inst_name = param.split('\\')[3];
current.instance_name = inst_name;



 

have a try...!!

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Yes, i will be using it in a business rule/// i will give it a try

Hello I tried it, and did not work, maybe there is something missing, i provided some snip its of the sql form, highlighted in yellow the 2 main fields, from running process to instance name fields and business rule, form, to fill out,  now the information in the running process key parameters is not the same, it will all be different... can you please advise.... 

Hi @Dallas2 

 

As you mentioned ,"running process key parameters" will be different - can you give us some more examples of running process key parameter values.

 

Follow the below steps for current scenario :

 

Step 1: Create Business rule  ( here for demo I have created Before - insert business rule )

So whenever record is created then it will update the instance name

 

VishalBirajdar_0-1696570071545.png

 

Script : 

 

(function executeRule(current, previous /*null when async*/ ) {

    /*get the running_process_key_parameters value */
    var param = current.getValue('running_process_key_parameters');

    if (param) {
        var inst_name = param.split('\\')[3];
        current.instance_name = inst_name;
    }
	
})(current, previous);

 

VishalBirajdar_1-1696570113652.png

 

Output : 

VishalBirajdar_2-1696570170131.png

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi Vishal,

 

here some examples how these will be different, will what you provided still parse out different data?