- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2017 10:01 PM
Hi All,
I am trying to validate the attachment type on submit of request, noticed that gel function is not supported with Istanbul version.
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
while (gr.next()) {
if(gr.getValue("content_type") != 'application/text'){//meaning if you find a file with xls extension
//do something
return false;
}
what is the alternative for gel('sysparm_item_guid').value ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 11:18 AM
Hi Vineeth,
g_form.getValue('sysparm_item_guid') should work correctly in scoped app. But the problem is you cannot use GlideRecord in client side in scoped app which leads to using GlideAjax in onSubmit client script. It also has one issue that is getXMLWait() doesn't work in scoped app.
So this post gives you workaround on the same.
But you can try one more option
Create Catalog client script in global scope for that catalog item and use following script then it will stop form submission. I have tried the same way and it worked for me for catalog item present in scoped app
Script:
var cat_id = gel('sysparm_item_guid').value;
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "sc_cart_item");
gr.addQuery("table_sys_id", cat_id);
gr.query();
if (!gr.next()) {
alert("Please add attachment");
return false;
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2017 10:18 PM
Hi Vineeth,
Are you referring on how to get a parameter that is incoming to something like a script include?
Please try something like:
var cat_id = this.getParameter('sysparm_item_guid');
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2017 05:36 AM
Hi Berny,
All the options you have posted are working fine in global application scope, but mine is a scoped application and they are not working in the scoped application..
I see that even gel('sysparm_item_guid').value is working in global application scope not in my application scope.
any help on this why they are not working in my application scope ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2017 10:20 PM
In case you were referring to the client code and the function of get element, try using g_form.getValue(variableName); instead
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2017 10:23 PM
Within a client script you can also try:
g_form.getControl('variableName').value;
Thanks,
Berny