- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 03:31 AM
HI
in workflow run script activity iam creating POST request to other application i am getting response 200
i need to move to next activity in workflow based on HTTP Response if response is 200 move to next activity in workflow if response is not equal to 200 i need to create a task below are the scripts i am using 1.run script in workflow to capture http response 2,"if activity "script to move forward next step if response is 200 not equal 200 need to create a task can anyone help me in scripts
script 1:
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
workflow.scratchpad.response = httpStatus;
script 2(if activity script)
function ifScript() {
var code = workflow.scratchpad.response;
gs.log('code is '+code);
if (code == 200) {
return 'yes';
}
else{
return 'no';
}
}
Kindly reply if further clarity on this question
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 05:08 AM - edited 11-29-2022 05:11 AM
Is this not working correctly? If not, what is in the log for 'code'? If it's not what is expected, log httpStatus and/or workflow.scratchpad.response in the previous script. If the log for 'code' is showing the expected value, try changing your if statement to
if (code == '200') {
since scratchpad variables are stored as a string. Also make sure your if activity script starts with a line to call the function
answer = ifScript();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 06:38 AM
This should work as long as you are getting 200 as a result.
answer = ifScript();
function ifScript() {
if (code == '200') {
return 'yes';
}
return 'no';
}
I have used response.getStatusCode() which I think returns '200 OK'
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 05:08 AM - edited 11-29-2022 05:11 AM
Is this not working correctly? If not, what is in the log for 'code'? If it's not what is expected, log httpStatus and/or workflow.scratchpad.response in the previous script. If the log for 'code' is showing the expected value, try changing your if statement to
if (code == '200') {
since scratchpad variables are stored as a string. Also make sure your if activity script starts with a line to call the function
answer = ifScript();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 11:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 06:38 AM
This should work as long as you are getting 200 as a result.
answer = ifScript();
function ifScript() {
if (code == '200') {
return 'yes';
}
return 'no';
}
I have used response.getStatusCode() which I think returns '200 OK'
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2022 11:11 PM - edited 11-29-2022 11:12 PM