
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 04:31 PM
Hi All
I have a service catalog item (accessed via service portal) for users to generate a QR code. It uses an onsubmit client script to call glide ajax. The ajax triggers a rest message to an external provider which generates the QR, and then takes the response back and gives it to the user. At the moment, i just pass the response back to the client script, which is the url to the qr image, and open it in a new tab. However it would be good if i could also take that response and pass it into a workflow associated with the catalog item. That way i can email the image url to the user in case they have some kind of issue with the new tab being opened, or lose the image or some other situation where they need to know it again in the future.
Initially I thought maybe if i have a hidden variable, and in the client script i take the response and populate the variable for use in the workflow. However, because i'm using the portal - i cant use getXMLwait to wait for the ajax to finish, so the variable is not able to be populated with anything.
is there any easy way to pass this info either into a variable on the catalog item as it is submitted, or to the workflow directly?
I might be able to call the workflow directly from the ajax i guess, but in an ideal world it would probably be better to have the WF associated with the request so i can add the URL to the comments etc. for further reference.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 09:33 PM
Can you try the below onSubmit() script format to set a variable with a script include response
function onSubmit() {
if (!g_form.ajaxComplete) {
ajaxCall();
return false;
}
}
function ajaxCall() {
var ga = new GlideAjax('script_include');
ga.addParam("sysparm_name", 'function_name');
getXMLAnswer(function(a){
// Set script include response into a variable
g_form.setValue('variable_name', a);
// Once you've handle the answer, run these two lines:
g_form.ajaxComplete = true;
g_form.submit();
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 09:33 PM
Can you try the below onSubmit() script format to set a variable with a script include response
function onSubmit() {
if (!g_form.ajaxComplete) {
ajaxCall();
return false;
}
}
function ajaxCall() {
var ga = new GlideAjax('script_include');
ga.addParam("sysparm_name", 'function_name');
getXMLAnswer(function(a){
// Set script include response into a variable
g_form.setValue('variable_name', a);
// Once you've handle the answer, run these two lines:
g_form.ajaxComplete = true;
g_form.submit();
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 10:01 PM
perfect! that worked brilliantly