Attach a file in Catalog Item as attachment and alert while submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 02:30 AM
Hi All,
I want to attach one Excel Sheet as an attachment in one Catalog Item so that whenever form loads the attachment will be visible and any user can download it.
And once the user downloads the attachment will fill it up and again attach the same.
While clicking on Submit I want an alert to be popup if user forgets to attach the file in the Catalog Item.
Can anyone let me know how to achieve this?
Thanks,
SNOW@Das

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 03:14 AM
Just add link to attachment, file in item description.
In order to get alert when submitting you will need add Catalog Client Script like this
function onSubmit() {
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()) {
g_form.addErrorMessage(getMessage('Alert You want'));
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 03:40 AM
Hi Slawek,
You mean to say that I need to add the attachment in the Catalog Item Description field and in the script you have mentioned i have some doubt.
The Catalog Client will be defined OnSubmit and as per the below script:
function onSubmit() {
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()) {
g_form.addErrorMessage(getMessage('Alert You want'));
return false;
}
}
What value should I mention in place of "table_name" and "table_sys_id"?
Kindly please let me know?
Regards,
SNOW@Das

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 03:45 AM
Hi
Yes you are right.
table_name is the coloumn name. keep it as it is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2018 03:51 AM
So you mean to say I should not make any changes in the Script?
I will keep it as it is and the Method will be only Onsubmit?
Correct me if I am wrong?