The CreatorCon Call for Content is officially open! Get started here.

Workflow scratchpad variable value is not kept in next activity of the workflow

vanessaheux
Tera Contributor

Hello guys

 I have an issue in my service catalog workflow.

I have a “run script” activity in which I call a REST API message

                r.setStringParameterNoEscape('iKeyrun', parseInt(workflow.scratchpad.EKeyrunSimulation, 10).toString());

                var response = r.execute();

                var responseBody = response.getBody();

                var httpStatus = response.getStatusCode();

                workflow.scratchpad.responseStatusSODCheck = httpStatus;

                gs.log('SOD Check httpStatus : '+httpStatus, 'SOD SAP');

 

Just after the rest API call, I can see in my logs that httpStatus had value 200 (which means everything is ok). And this httpStatus is also set in scratchpad variable workflow.scratchpad.responseStatusSODCheck.

 

Just after, in the workflow, I defined an “If” activity to check workflow.scratchpad.responseStatusSODCheck in order to create a manual task (in order to check why we had issue) if the status is different from 200 or to continue the workflow if not.

  answer = ifScript();

  function ifScript() {

     if (workflow.scratchpad.responseStatusSODCheck == '200') {

        return 'yes';

     }

     return 'no';

  }

 

My issue is that even if the logs are showing value 200, the second activity (“if”) acts as if I didn’t have value 200 and thus creates me a manual task. And I know and I’m sure because I checked it everything has been done correctly with the REST API message.

 

This issue does not happen always. Most of the time it is ok but I can’t get what makes it sometimes wrong as the logs are saying the contrary.

 

Did you already face such an issue?  It seems that it could be a problem of network or lag in setting the workflow scratchpad variable but it seems so strange.

Thanks to give your idea if you have any.

Vanessa

3 REPLIES 3

Prasad Pagar
Mega Sage

Hi @vanessaheux 

Can you please mark scratchpad variable to blank first like below

r.setStringParameterNoEscape('iKeyrun', parseInt(workflow.scratchpad.EKeyrunSimulation, 10).toString());

                var response = r.execute();
 workflow.scratchpad.responseStatusSODCheck = '';
                var responseBody = response.getBody();

                var httpStatus = response.getStatusCode();

                workflow.scratchpad.responseStatusSODCheck = httpStatus;

                gs.log('SOD Check httpStatus : '+httpStatus, 'SOD SAP');

Thank you
Prasad

Hello Prasad

Why do you propose this?

How do you explain that this change could change the issue?

In case your integration failed and Http status didnt come or anything goes wrong it will always hold value from old context. It happened with me too 🙂

Clearing it is always better option. May be you can try and see if it works out for you