code snippet flow designer

levino
Giga Guru

Hi there

not sure if something is wrong with the below, the catalog item its not calling the below flow, i have it as scripted task on the catalog item.

 

when it test it manually using the flow,  the REST part of the flow works perfectly well.

 

on the catalog item, i have another workflow, and then on the task  on the catalog item i have the code snippet as per below

 

Thanks

Levino

 

 

 

 

(function() {

    try {
        var inputs = {};
        inputs['table_name'] = 'Requested Item';
        inputs['current']; // GlideRecord of table: sc_req_item 

        // Start Asynchronously: Uncomment to run in background.
        sn_fd.FlowAPI.getRunner().flow('global.uff_integration').inBackground().withInputs(inputs).run();

        // Execute Synchronously: Run in foreground.
        //sn_fd.FlowAPI.getRunner().flow('global.uff_integration').inForeground().withInputs(inputs).run();

    } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
    }

})();

 

1 ACCEPTED SOLUTION

Sumanth16
Kilo Patron

Hi @levino ,

 

Please try below code:

 

 

(function() {
    
    try {
        var sctaskGR = new GlideRecord('sc_req_item');
        if (sctaskGR.get('sys_id_of_a_specific_sc_task_record')){
            var inputs = {};
            inputs['current'] = sctaskGR; // GlideRecord of table:  
            inputs['table_name'] = 'sc_req_item';

            // Start Asynchronously: Uncomment to run in background.
            // sn_fd.FlowAPI.getRunner().flow('global.xyz').inBackground().withInputs(inputs).run();
                
            // Execute Synchronously: Run in foreground.
            sn_fd.FlowAPI.getRunner().flow('global.uff_integration').inForeground().withInputs(inputs).run();
        }
        else{
            gs.warn('Not a valid record of SCTASK');
        }
        
        
    } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
    }
    
})();

 

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

View solution in original post

3 REPLIES 3

Sumanth16
Kilo Patron

Hi @levino ,

 

Please try below code:

 

 

(function() {
    
    try {
        var sctaskGR = new GlideRecord('sc_req_item');
        if (sctaskGR.get('sys_id_of_a_specific_sc_task_record')){
            var inputs = {};
            inputs['current'] = sctaskGR; // GlideRecord of table:  
            inputs['table_name'] = 'sc_req_item';

            // Start Asynchronously: Uncomment to run in background.
            // sn_fd.FlowAPI.getRunner().flow('global.xyz').inBackground().withInputs(inputs).run();
                
            // Execute Synchronously: Run in foreground.
            sn_fd.FlowAPI.getRunner().flow('global.uff_integration').inForeground().withInputs(inputs).run();
        }
        else{
            gs.warn('Not a valid record of SCTASK');
        }
        
        
    } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
    }
    
})();

 

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

Hi Sumanth

 

the workflow on the cat item has this for the scripted fulfilment task and i am putting your code in the  scripted task.

i tried with your code , no luck

Thanks

Levino

 

evaluateScriptedTask();

function evaluateScriptedTask() {
    var vars = {
        'RITM': workflow.scratchpad.req_id
    };
    var apr_rec = new GlideRecord('u_catalog_task_assignment');
    apr_rec.get(workflow.scratchpad.taskID);
    var evaluator = new GlideScopedEvaluator();
    var result = evaluator.evaluateScript(apr_rec, 'u_script', vars);
}

 

var rec = new GlideRecord('sc_req_item');
rec.get(RITM);