client callable script include not working in scoped application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2024 12:20 PM
Hi everyone,
I'm working on a custom table inside scoped application, and I'm trying to execute an OnSubmit client script which calls script include (defined in same scope), but so far.. either I got null response or no response at all. below are my scripts which are pretty simple but not behaving as expected. basically Im trying to make attachment mandatory on form.
client script:
script include:
have referred multiple community articles and solved queries, nothing seem to work. "sys_attachment" is made available to all scopes.
Regards,
Ubada Barmawar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 09:47 AM
Hi Ubada,
As Maroon said, you should call hasAttachments instead of hasAttachment in client script. Along with that, before line number 8 which is gr.query(), I would suggest to use gr.setLimit(1) as it will be better in terms of time complexity as we just need 1 record.
Thanks,
Brahm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 04:21 AM
it doesnt work even if I correct the spelling. attachments are unique for each record created and can be filtered using record sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 10:11 AM
Hi @Ubada Barmawar ,
Can I recomend just create a business rule instead of client script on the onSubmit page, then its need to look like:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.query();
if(gr.hasNext()){
gs.log("yes"); //navigate to the syslog table to look the message
} else{
gs.log("no");
// you can abort the submit is not have a attachment file
gs.addErrorMessage('Insert attachment file.');
current.setAbortAction(true);
}
})(current, previous);
Hope that help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 04:19 AM
I already have tried with business rule, It gives info message as record inserted ...also some unneccessary messages are displayed. client script is what I want anyhow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 04:31 AM - edited 04-15-2024 04:33 AM
Change the following:
- getXMLWait should be getXMLAnswer if you want to use a callback (see the docs for getXMLWait on how to use that if that's what you want to use instead)
- As others have pointed out, use hasAttachments not hasAttachment
- As James pointed out, you'll need to call g_form.submit() with the appropriate action to resubmit the form depending on the response you get back (and will need to return false outside your callback to prevent the form submission originally)