- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 02:30 PM
I have the below UI Macro working fine to show related Incidents, based on the Short Description. However, I only want the UI Macro button to appear when the g_form is the Incident table. What am I missing? The button keeps appearing for Requests, which is undesirable.
UI Macro
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
<g:reference_decoration id="${jvar_n}" field="${ref}"
onclick="showRelatedIncidentsByShortDescription('${ref}');"
title="${gs.getMessage('Show related Incidents')}" image="images/icons/tasks.gifx" icon="icon-tree-right" />
<script>
function showRelatedIncidentsByShortDescription(reference) {
try {
var shortDescription = g_form.getValue('short_description');
var title = 'Short Description contains: ' + shortDescription;
var query = 'short_descriptionLIKE' + shortDescription;
var gdw = new GlideModal('show_list');
gdw.setTitle(title);
gdw.setSize(750);
gdw.setPreference('table', 'incident_list');
gdw.setPreference('sysparm_query', query);
gdw.render();
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>
Client Script
function onLoad() {
//Type appropriate comment here, and begin script below
var tbl = g_form.getTableName();
if(tbl == 'incident')
{
document.getElementById("${jvar_n}").style.display = 'inline';
}
else
{
document.getElementById("${jvar_n}").style.display = 'none';
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 02:55 PM
What field did you set this macro on in the form? Depending on the field that extends from Task, like short description, if you add it directly to the dictionary it can cascade to other tables where you may not want it to.
Have you tried adding a dictionary entry override for that table and field and override the attribute for that macro. That will isolate it to the one table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 02:53 PM
Hi,
Cab you try with this as cliient script
function onLoad() {
//Type appropriate comment here, and begin script below
var tbl = g_form.getTableName();
if(tbl == 'incident')
{
document.getElementById("${jvar_n}").style.display = 'block';
}
else
{
document.getElementById("${jvar_n}").style.display = 'none';
}
}
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2019 02:55 PM
What field did you set this macro on in the form? Depending on the field that extends from Task, like short description, if you add it directly to the dictionary it can cascade to other tables where you may not want it to.
Have you tried adding a dictionary entry override for that table and field and override the attribute for that macro. That will isolate it to the one table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2019 04:37 AM
MB, the field for the UI Macro is for the Short Description, which is from the Task table. Again, I only want the UI Macro to show if the base table is the Incident table (not Request table). Thus, being able to override the attributes of the Short Description field, based on the table is the ideal solution. Thanks for your help!!