- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 06:19 AM - edited 05-05-2023 06:20 AM
How to add attachment as a link in an error message, when the attachment variable is empty for a catalog item.
Sample screenshot attached for reference.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 07:12 AM - edited 05-05-2023 07:15 AM
Try this
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=6dc35515db74bf00db9b9875db9619f2">Download Template</a>'; //replace the sys_id with actual template attachment record sysid.
var message = gs.getMessage('add your message here') + ' ' + link + ' ';
gs.addInfoMessage(message); //you can use addInfoMessage or addErrorMessage accordingly.
if you want to open the template in new tab and download then use this
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=6dc35515db74bf00db9b9875db9619f2" target = "_blank">Download Template</a>'; //replace the sys_id with actual template attachment record sysid.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 08:52 AM
Hi @Voona Rohila,
Made some minor changes to your code and attached the same below. Thanks for your support. 🙂
function onCondition() {
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=2981a87647222110dc3b690cd36d4325">Download Template</a>';
g_form.addErrorMessage('Please attach before submitting :' +' ' + link + ' ');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 07:12 AM - edited 05-05-2023 07:15 AM
Try this
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=6dc35515db74bf00db9b9875db9619f2">Download Template</a>'; //replace the sys_id with actual template attachment record sysid.
var message = gs.getMessage('add your message here') + ' ' + link + ' ';
gs.addInfoMessage(message); //you can use addInfoMessage or addErrorMessage accordingly.
if you want to open the template in new tab and download then use this
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=6dc35515db74bf00db9b9875db9619f2" target = "_blank">Download Template</a>'; //replace the sys_id with actual template attachment record sysid.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 08:52 AM
Hi @Voona Rohila,
Made some minor changes to your code and attached the same below. Thanks for your support. 🙂
function onCondition() {
var link = '<a href="/nav_to.do?uri=sys_attachment.do?sys_id=2981a87647222110dc3b690cd36d4325">Download Template</a>';
g_form.addErrorMessage('Please attach before submitting :' +' ' + link + ' ');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2023 09:15 AM - edited 05-05-2023 09:17 AM
My solution was to provide the logic so that you can use the same in your code according to your requirements. Can you please mark my response as correct.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP