- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
How to show a downloadable xl file link conditionally when user selects one of the choice in a dropdown field in service portal?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Steps
1) add file to your catalog item, get the sysId of sys_attachment record sysId
2) create variable of type URL and add the relative URL there in default value, use the correct sysId from the above step in this
3) then write onChange on your other variable to show/hide the URL and another UI policy to make URL variable read-only always so that users don't change it
Output:
I hope this answers your question and you can enhance it further from here based on your developer skills and requirements
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
this is possible with this approach
1) store that excel on your catalog item record, grab the sys_attachment sysId for that file from sys_attachment table
2) then use onChange catalog client script on that select box
a) use g_form.addInfoMessage() and show the link to download the file
Something like this
Give correct sysId from sys_attachment, correct choice values to compare
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var link1 = '<a href="/sys_attachment.do?sys_id=sysId1" target="_blank">Click here to download Template 1</a>';
if (newValue == 'choiceValue1') {
// Add the info message with the link
g_form.addInfoMessage(link1);
} else {
g_form.clearMessages();
}
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi, this is working, thank you so much! However, the info message disappears after few seconds. Are there any other solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Glad to know that my approach worked.
I believe I answered your original question where you wanted a link for user to download file.
Now that you require some other approach, I can share that but you can mark the above response as correct to close the thread.
The discussion can continue on answered thread.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
