- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 12:08 AM
Hello everybody,
I am trying to create an if condition within a service catalog workflow. The advanced script looks as follows:
answer = ifScript();
function ifScript() {
if (current.variables.delivery_address == "Test") {
return 'yes';
}
return 'no';
}
It returns always no, even thoug I type "Test" in the Delivery Address field in checkout screen. It doesn't matter, which variable (u_cost_center, price etc.) of the requested item i use. It returns always 'no'.
Hopefully anybody can tell me, why it's not working.
Thanks a lot and best regards
Andreas John
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 03:15 AM
you condition should be
if (current.request.delivery_address == "Test") {
as deliver address is on request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 05:25 AM
Thank you, but following script still returns 'no'.
answer = ifScript();
var someText = current.request.delivery_address;
someText = someText.replace(/(\r\n|\n|\r)/gm,"");
function ifScript() {
if (someText == "Line1,Line2") {
return 'yes';
}
return 'no';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 05:35 AM
Can you try this
answer = ifScript();
function ifScript() {
var someText = current.request.delivery_address;
someText = someText.replace(/(\r\n|\n|\r)/gm,"");
if (someText == "Line1,Line2") {
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 05:54 AM
It still returns 'no'..
Do you have another solution regarding this issue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 06:00 AM
When I have tested in the background script it went to if loop. I'm not sure what you are missing..
Can you make sure that line1 is ending with ,
var someText = current.request.delivery_address;
someText = someText.replace(/(\r\n|\n|\r)/gm,"");
gs.log(someText);
if (someText == "Roswell, GA,USA") {
gs.log('yes');
}
else{
gs.log('no');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2017 06:30 AM