- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 06:27 PM - edited 07-27-2023 06:30 PM
Hi Guys,
Looks like I am missing something. I have a simple subflow that I am calling from a script include and it's not working.
Client Script:
------------------------
Script Include
var MobilityUtils = Class.create();
MobilityUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
countDevice: function() {
try {
//gs.info('deviceCount', 'Mobility');
var userSysID = this.getParameter('sysparm_id');
//gs.info('userSysID = ' + userSysID, 'Mobility');
var inputs = {};
inputs['user_sysid'] = userSysID; // GlideRecord of table: sys_user
var result = sn_fd.FlowAPI.getRunner().subflow('x_rrdu2_mobility_e.mobility__number_of_devices_own_by_the_user').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
var devicecount = outputs['devicecount']; // Integer
//gs.info('devicecount = ' + devicecount, 'Mobility');
return devicecount;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
},
type: 'MobilityUtils'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 12:27 PM
Hi Tony,
I got an error - "Invalid GlideRecord input format found"
Then I found this article - https://www.servicenow.com/community/developer-forum/invalid-gliderecord-input-format-found/td-p/253...
This fixed the issue.
I changed my script to add the GlideRecord part:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 07:34 PM
Hi, what are the results of your investigation\diagnostics? Have you confirmed that your client script is triggered, the GlideAjax call is made and that the GlideAjax function runs? Have you confirmed that your script-include is client callable, that the values passed in by your gliadeAjax parameter is correct and that the correct value is set in 'inputs'
Does your flow call complete\return any results, good or bad?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 07:46 PM
Hi Tony,
Thanks for responding to my question.
The client script is being triggered and I get a null as the answer. However, I don't see any executions on the subflow. When I run a test in the subflow it works.
I added logs in the script include, but I dont see any log. For scope application does gs.log works? I also tried to hardcode the parm being sent to script include and it is still not working.
I also tried to run the subflow code snippet in the background script and it also doesn't work, but then again the subflow works by itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2023 08:13 PM
Hi, I would expect logging\info messages to work in the script-include.
Did you add ACL\assign suitable role to the script-include (normally via popup on save).
Is the usage in the same scope, is the script-includes 'Acessible from' field set correctly.
Have you tried setting the full API name for the ajax scripts sysparm_name value on client script
'global.countDevice' or (I am guessing) 'x_rrdu2_mobility_e.countDevice'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2023 12:27 PM
Hi Tony,
I got an error - "Invalid GlideRecord input format found"
Then I found this article - https://www.servicenow.com/community/developer-forum/invalid-gliderecord-input-format-found/td-p/253...
This fixed the issue.
I changed my script to add the GlideRecord part: