How to call script include in flow action.

martin63
Tera Contributor

Hello All,

I have script include and flow with custom flow action and they are OOB. But while triggering it facing issue as 

Error: ErrorMethodName: changeStartDate ## Empty JSON string Source: Process Automation.sys_idFlowAction lineNumber: 2 (sys_script_include.sys_id.script; line 588)
 
Below is custom action and in flow it is called and flow is triggered while creating HR case also in this flow action no output is given and in script include fuction (inputs,outputs) these 2 parameter are passed.
 
Thankyou!!
Any solution/assistance...
find_real_file.png
 
7 REPLIES 7

@Ankur Bawiskar Script include and flow is in same scope

changeStartDate: function(inputs,outputs ) {
        gs.info('test 1' + inputs +  ' ' + outputs );
        try {

            // pre-process payload
            var currentCaseGr = inputs.currentCase;
                            gs.info('test 2 ' + currentCaseGr);

            var payload = JSON.parse(currentCaseGr.payload);
                gs.info('test 3 ' + payLoad);
             gs.info('test 4' + JSON.stringify(payLoad));

            var startDate = payload.what_should_the_new_employee_s_start_date_be;
        
            if (gs.nil(startDate)) {
                var payloadStartDateNullErrMsg = this._formatUtil.format(
                    'Change start date flow: new start date not populated for case: {0}.',
                    currentCaseGr.getUniqueValue());
                throw this._errorUtil.getError(payloadStartDateNullErrMsg);
            }

            var parentCaseGr = currentCaseGr.parent.getRefRecord();
            var parentCaseSysId = parentCaseGr.getUniqueValue();

            if (!parentCaseGr.isValidRecord()) {
                var parentCaseNotValidErrMsg = this._formatUtil.format(
                    'Change start date flow: parent case: {0} not valid.', parentCaseSysId);
                throw this._errorUtil.getError(parentCaseNotValidErrMsg);
            }

            this._changeSubjectPersonJobStartDate(parentCaseGr, startDate);
            this._changeSubjectPersonProfileStartDate(parentCaseGr, startDate);
            this._changeTaskDueDate(parentCaseSysId);

            // update the 'Change start date' case to 'Closed complete' state
            currentCaseGr.state = 3;
            currentCaseGr.update();
            this._errorUtil.validateGrForError(currentCaseGr);
        } catch (error) {
            throw this._errorUtil.handleExceptionMethod('changeStartDate', error);
        }
    },

Abhijit4
Mega Sage

Looks like something is wrong with script include line number 588.

Could you please share script include code if possible so that everyone can help you further.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit
Community Rising Star 2022

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP

@Abhijit  okay please check above script below this line" var currentCaseGr = inputs.currentCase; " it direct executes  catch block.