How to execute fill.fc from javascript

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

Could you help me?

  • 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.

     

  • 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;
    }
  • what is your intent ?

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

  • what is your intent ?

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

  • what is your intent ?

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

  • Verified Answer

    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
    }

  • 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