Highlighted
Honored Contributor.
Honored Contributor.
1251 views

How to execute fill.fc from javascript

Jump to solution

Hi experts, I need to run the RAD "fill.fc" in a trigger.

Could you help me?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: How to execute fill.fc from javascript

Jump to solution

Hi,

here is the OOB example of how to call RAD from JS (you could find it in SL "CallRAD"):

function callUsLink(record,field,format,action){
//action "fill", "find"
//params:
//record=record
//name=field
//string1=format
//prompt=action
if (action!="fill" && action!="find"){
print("Wrong action given for us.link");
return;
}
var rteReturnValue = new SCDatum();
var rteNames = new SCDatum();
var rteValues = new SCDatum();

rteNames.push("record");
rteNames.push("name");
rteNames.push("string1");
rteNames.push("prompt");
rteNames.push("boolean1");

rteValues.setType(8);
rteValues=system.functions.insert(rteValues, 0, 1, record);
rteValues=system.functions.insert(rteValues, 0, 1, field);
rteValues=system.functions.insert(rteValues, 0, 1, format);
rteValues=system.functions.insert(rteValues, 0, 1, action);
rteValues=system.functions.insert(rteValues, 0, 1, true);

system.functions.rtecall("callrad",
rteReturnValue,
"us.link", //RAD app name
rteNames,
rteValues,
false); //false to run in same thread, true to run in new thread
}

View solution in original post

5 Replies
Highlighted
Honored Contributor.. Honored Contributor..
Honored Contributor..

Re: How to execute fill.fc from javascript

Jump to solution

Generically, any RAD function can be called using invokeRAD JS Function.

Usage:

    var response = invokeRAD(applicationName, parameters)

Where parameters is a JS Array with the values for the "input fields" in order.

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: How to execute fill.fc from javascript

Jump to solution

For example?

I generate the following lines of code, but it does not work.

var rc;
var aNames = new Array("record", "text", "string1");
var aValues = new Array( oldrecord, "assignment", "configurationItem");

    var params = [
        output_File( 'file', record ),// $RECORD
        input_String( 'text', "assignment" ),// $INTO.FIELD
        input_String( 'string1', "configurationItem" ),// $INTO.FILENAME
    ];



//system.functions.rtecall("callrad", rc, "fill.fc", aNames, aValues, true);
invokeRAD( 'fill.fc', params )



function invokeRAD( radName, params ) {

    if( log.isDebug( 'invokeRAD' ) ) log.debug( "invokeRAD: " + radName );
    
    var rteNames = [];
    var rteValues = [];
    var parmTypes = [];
    var resultNames = [];
    var resultTypes = [];
    for( var i=0; i<params.length; i++ ) {
        rteNames.push( params[i].getParamName() );
        rteValues.push( params[i].getParamValue() );
        parmTypes.push( params[i].getParamType() );
        if( log.isDebug( 'invokeRAD' ) ) {
            log.debug( "paramName: " + params[i].getParamName()
                        + ", paramValue: " + params[i].getParamValue()
                        + ", paramType: " + params[i].getParamType() );
        }
        if( params[i].isOutput() ) {
            resultNames.push( params[i].getParamName() );
            resultTypes.push( params[i].getParamType() );
        }
    }
    var resultValues = {};
    var result = runRAD( radName, rteNames, rteValues, parmTypes, resultNames );
    var __results = result.results;
    if( __results != null && __results.length() <= resultNames.length ) {
        for( var j=0; j<__results.length(); j++ ) {
            switch( resultTypes[j] ) {
            case SMType_File: case SMType_Array:
                resultValues[ resultNames[j] ] = system.functions.val( __results[j], resultTypes[j] );
                break;
            default :
                resultValues[ resultNames[j] ] = __results[j];
            }
            if( log.isDebug( 'invokeRAD' ) ) {
                log.debug( "resultName: " + resultNames[j] + ", value: " + resultValues[ resultNames[j] ] );
            }
        }
    }

    return resultValues;
}
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: How to execute fill.fc from javascript

Jump to solution

what is your intent ?

you need to click fill for a field to start a link ?

Highlighted
Trusted Contributor.
Trusted Contributor.

Re: How to execute fill.fc from javascript

Jump to solution

Hi,

here is the OOB example of how to call RAD from JS (you could find it in SL "CallRAD"):

function callUsLink(record,field,format,action){
//action "fill", "find"
//params:
//record=record
//name=field
//string1=format
//prompt=action
if (action!="fill" && action!="find"){
print("Wrong action given for us.link");
return;
}
var rteReturnValue = new SCDatum();
var rteNames = new SCDatum();
var rteValues = new SCDatum();

rteNames.push("record");
rteNames.push("name");
rteNames.push("string1");
rteNames.push("prompt");
rteNames.push("boolean1");

rteValues.setType(8);
rteValues=system.functions.insert(rteValues, 0, 1, record);
rteValues=system.functions.insert(rteValues, 0, 1, field);
rteValues=system.functions.insert(rteValues, 0, 1, format);
rteValues=system.functions.insert(rteValues, 0, 1, action);
rteValues=system.functions.insert(rteValues, 0, 1, true);

system.functions.rtecall("callrad",
rteReturnValue,
"us.link", //RAD app name
rteNames,
rteValues,
false); //false to run in same thread, true to run in new thread
}

View solution in original post

Highlighted
Honored Contributor.
Honored Contributor.

Re: How to execute fill.fc from javascript

Jump to solution

KVA, thank you very much!
Add the following code in a "Before updating" trigger. 

var rteReturnValue = new SCDatum();
var rteNames = new SCDatum();
var rteValues = new SCDatum();

rteNames.push("record");
rteNames.push("text");
rteNames.push("string1");

rteValues.setType(8);
rteValues=system.functions.insert(rteValues, 0, 1, record);
rteValues=system.functions.insert(rteValues, 0, 1, "assignment");
rteValues=system.functions.insert(rteValues, 0, 1, "configurationItem");


system.functions.rtecall("callrad",
rteReturnValue,
"fill.fc", //RAD app name
rteNames,
rteValues,
false); //false to run in same thread, true to run in new thread

 

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.