What is the alternative way to use gel() in service portal..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 05:41 AM
Hi Team,
Can any body let me the alternative way of gel() in service portal.
i have written this onSubmit script, which works fine in CMS,
Here i need to get value of sysparm_item_guid, how do I get with out using gel() method?
I am attaching the code:
var cat_id = gel('sysparm_item_guid').value;
var sp = new GlideRecord("sys_attachment");
sp.addQuery("table_name", "sc_cart_item");
sp.addQuery("table_sys_id", cat_id);
sp.query(function(){
if (!sp.next()) {
g_form.addErrorMessage("Please attach the required SSL certificates/document");
return false;
}
});
Any help or suggestion will help me lot
Thanks,
Nithin.
- Labels:
-
Service Catalog
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 05:47 AM
Hi Nitin,
The approach I would take is to use an ng-click handler and use your client script to make a REST call to determine if the attachment is available. A Scripted REST API would be very helpful here as it gives you total control over the inputs and outputs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 06:17 AM
Hi Nithin,
You can't use any dom manipulation techniques in the service portal, but you can grab the sys_id of your catalog item with g_form.getSysId() and that should work in Service Portal. Here's a good list of what is and isn't supported in SP.
documentation/client_scripting.md at master · service-portal/documentation · GitHub
Also, instead of the client side gliderecord, you could use a script include and glideajax to determine whether or not your item has an attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2018 04:30 AM
Thanks Brad 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 07:51 AM
Thanks for your reply .
I have one query.. How to make onSubmit script to stop in servcie portal ..as in service portal we can only write asynchronous call only.
for example see below mwntioned code .. where I need to stop the submission of form if it doesn't have any attachments,But issue is in service portal we need to write only asynchronous methods, so before getting data regarding attachments from is submitting.
function onSubmit() {
g_form.clearMessages();
//var cat_id = gel('sysparm_item_guid').value;
var cart_id = g_form.getSysId();
var sp = new GlideRecord("sys_attachment");
sp.addQuery("table_name", "sc_cart_item");
sp.addQuery("table_sys_id", cart_id);
sp.query(function(sp){
if (!sp.next()) {
g_form.addErrorMessage("Please attach the required SSL certificates/document");
return false;
}
});
}
Is there ant other way i can achieve this ?
thanks,
Nithin.
