Business rule to parse value

Lupe Pina
Tera Contributor

Hello,

Can anyone look at the script below in the business rule, and how can I modify it to get different values or look for either values, from the running key process parameters field, from the two examples I provided. and parse the value(S) MSSQL15.RMAD AND/OR MSSQL15.MSSQLSERVER, and put in the instance name field.

1 REPLY 1

Carlos Loza
Tera Expert

Hello,

 

if you need to extract the instance name, the best approach would be to modify the pattern related to MSSQL instance and extract the instance name with a parsing step, then map it to the instance name field

it is sometimes more flexible that way

 

alternatively

 

if you have to use the BR, 

I suggest using regex to extract the instance name, having in mind that it will have some constraints depending on things like naming convention of the SQL instance name, 

the match function works in extracting the instance name in both of your cases, with that regex:

 

 

var paramTesting1 = '"E:\SQLExpress\MSSQL15.RMAD\MSSQL\Binn\sqlserver.exe" -sRMAD';
var paramTesting2 = '"E:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\sqlserver.exe" -sMSSQLSERVER';

var regex = /MSSQL15\.RMAD|MSSQL15\.MSSQLSERVER/gm;

gs.info(paramTesting1.match(regex)[0]); //match returns an array with first element of the array being the first match (if there are multiple): returns MSSQL15.RMAD