- 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-22-2017 06:09 AM
Hi Vineeth,
Following link provides an approach:
How to fix onSubmit data validation once and for all in Scoped Applications
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-22-2017 08:34 AM
Hi Ankur,
g_form.getValue('sysparm_item_guid') is giving different values when used in global scope and in my application scope... in global scope it is giving the table_sys_id of the record in sys_attachment table, in my application scope it giving some id not sure what is that id..
- 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-24-2017 02:01 AM
Hi Vineeth,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
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-28-2017 01:01 AM
Hi Vineeth,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader