- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2017 02:54 PM
I have a script I want to execute depending on if the answer for a script include returns true or false. I invoke the script include at the beginning of my script and want to add if "if/else" statement to decide wether or not the script should execute. How can I do this?
(Script I want to execute if script include returns true)
(Script include)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2017 03:10 PM
Hello Josh,
var slack = new SlackUser();
var res = slack.activeUser(); //This would return true or false depeding on the output from Script include.
Please let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2017 03:10 PM
Hello Josh,
var slack = new SlackUser();
var res = slack.activeUser(); //This would return true or false depeding on the output from Script include.
Please let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2017 04:37 PM
Hi Pradeep - I tried this, but no luck:
var slack = new SlackUser();
var res = slack.activeUser()
if (res = false)
{
answer += 'Test'
}
else {
//do this
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2017 03:14 PM
when calling the script include, you want to include which function to call:
var slack = new GlideAjax('SlackUser');
slack.addParam('sysparm_name','activeUser');
slack.getXML(callback);
Then, in that same script, you want to add a callback function:
function callback(response){
var ans = response.responseXML.documentElement.getAttribute("answer");
if(ans == true){
//what you want to do
}
else{
//what you want to do
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2022 06:16 AM
If I use onSubmit client script
and if Script include returns false, then Form should not submit.
what should I use for this? and where?