Synchronous call to flow designer API throwing exception 'The current execution is in the waiting state'

kc1959
Tera Contributor

Hello,

we are trying to perform some 'front end validation' (FEV) when a user submits a catalog item in the portal.

The intention is that, on submission of the catalog item:

1. We call the flow designer subflow as shown in the code below

2. The flow will perform a REST call to look up our Active Directory (AD) and ensure that the users selected on the form exist in AD

3. If we get a 'failure' response from the sn_fd.FlowAPI.getRunner().subflow call, we display a warning/error message to the user and abort the form submission

Unfortunately the REST call appears to wait for available threads and this results in a failure of 'The current execution is in the waiting state' in the exception 'catch' code as detailed below.

Has anyone encountered this previously and perhaps has a workaround? 

We can't execute this asynchronously as we need this validation check to occur within a few seconds if submission.

 

From the SN documentation:

Exception The API throws an exception when a flow called synchronously pauses. The current execution is in the waiting state. In most cases, the exception is removed when the flow resumes. However, the API cannot resume a flow that has been sent to a MID Server.

 

The script include code that is called:

            var resultF = sn_fd.FlowAPI.getRunner().subflow('global.front_end_su_validation_control_flow').inForeground().withInputs(inputs).run();
            gs.log('the callValFlow returned - here 1', 'xxxxx');
            var outputs = resultF.getOutputs();
            gs.log('Jthe callValFlow returned outputs = ' + outputs, 'xxxxx');


            // Get Outputs:
            // Note: outputs can only be retrieved when executing synchronously.
            var result = outputs['result']; // String
            var respmess = outputs['respmess']; // String

            gs.log('IDAM FEV result is ' + result + ' respmess is ' + respmess, 'xxxxx');

            //CL: encode JSON
            var json = new JSON();
            var data = json.encode(outputs); //JSON formatted string   
            gs.log('IDAM FEV data is ' + data, 'xxxxx');
            return data;

        } catch (ex) {
            var message = ex.getMessage();
            gs.log('IDAM validation failed and entered CATCH statement - error message is = ' + message, 'xxxxx');
            gs.error(message);
        }

1 REPLY 1

tstocking
Tera Guru

Did you ever get a resolution to this? We are running into the same issue currently.

 

Thanks,

Todd