How to call a script include via Business rule

Saurabh Singh5
Tera Expert

Can some one please let me know, How we can call a Script include via a Business rule. Example I have an existing client callable script include which returns true/false as the output i need to use the same in the Business rule for me to set up an error message.

 

Example:

I am currently using it like this:

var fun =new functionname().getValue(); // passing the (script include name.function name)
var ans = fun.getValue();
Need to understand how to get the true false value from script include to utilize it here in the BR
1 ACCEPTED SOLUTION

maheshkhatal
Mega Sage

@Saurabh Singh5 Please see below the format/syntax to call a script include from BR.

// Instantiate the Script Include
var scriptInclude = new ScriptIncludeName(); // Replace with the name of your Script Include

// Call the function and capture the return value
var result = scriptInclude.functionName(); // Replace with the name of your function

// Use the result in your Business Rule logic
if (result) {
    gs.addErrorMessage("Your error message here"); // Set an error message if the result is true
} else {
    // Proceed with other logic if the result is false
}

 

Mark my response as helpful if it resolves your doubt let me know if you are facing any issue.

Thanks,

Mahesh.

View solution in original post

4 REPLIES 4

Saurabh Singh5
Tera Expert

Hi @Ankur Bawiskar 

 

Tagging you as requested, Please explain the syntax, thank you in advance

satyaprakas
Tera Expert

Hi @Saurabh Singh5 ,

 

Please try using below format

 

var func=new ScriptIncludeName().functionName();

 

Please mark my solution as accepted and give thumbs up, if it helps you.

Regards,

Satya

maheshkhatal
Mega Sage

@Saurabh Singh5 Please see below the format/syntax to call a script include from BR.

// Instantiate the Script Include
var scriptInclude = new ScriptIncludeName(); // Replace with the name of your Script Include

// Call the function and capture the return value
var result = scriptInclude.functionName(); // Replace with the name of your function

// Use the result in your Business Rule logic
if (result) {
    gs.addErrorMessage("Your error message here"); // Set an error message if the result is true
} else {
    // Proceed with other logic if the result is false
}

 

Mark my response as helpful if it resolves your doubt let me know if you are facing any issue.

Thanks,

Mahesh.

SharanjeetS
Tera Contributor

Script Include:

 

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
    initialize: function() {
    },

myFunction: function(){
                
                gs.info('Testing');
                
        },
        
    type: 'MyScriptInclude'
};

 

 

BR:

new MyScriptInclude().myFunction();

 

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

Regards,

Sharanjeet Singh