Trying to add display text to a URL field type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 01:04 PM
Hi Community,
I have a script that is populating a HTML link into a field type of URL. The script and link are working perfectly but since the full URL in the link column takes up a good portion of list view screen, I'm trying to figure out if it is possible to change the syntax to use a displayed text string instead of the full link yet keep the link functional. Trying to incorporate <a href> tags doesn't work. I'm wondering if anyone else has done this or has any ideas.
Thank you,
Jeff Franklin
Simplified Code Excerpt:
var myLink=gs.getProperty('glide.servlet.uri') + 'time_card_list.do?sysparm_query=user.name%3D' + myList[c-1][1];
tcs.u_link = myLink;
tcs.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 01:30 PM - edited 02-14-2024 01:43 PM
I found another solution because this worked only on OOTB fields. So I have created UI Macro - UI Formatter and onLoad Client Script.
I get value from the source URL field and set it to Formatter hyperlink. Source fields are hidden then with boolean field and user must check it to show them.
UI Macro
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null">
<a id="<custom_name_for_element>" href="" target="_blank">Label of the link</a>
</j:jelly>
Client Script (onLoad) that sets value for hyperlink or hide it if empty. Isolate Script must be False.
function onLoad() {
var url = g_form.getValue('source_field');
if (url != '') {
document.getElementById("custom_name_for_element").href = url;
} else {
document.getElementById("custom_name_for_element").hidden = true;
}
}
User checks to show source fields
After save the field is unchecked because Business Rule and only links are visible