Icon next to Request Number to show related Requested Items?

Edwin Fuller
Tera Guru

Need to add an reference icon next to the Request Number field similar to how the "Show Related Incidents" icon appears next to the "Caller" field. Has anyone done this before or can show me how to accomplish this?

1 ACCEPTED SOLUTION

Prateek kumar
Mega Sage

Hello Edwin


This article should help you


Show related incidents


Navigate to system definition> UI macros


1. create a new UI macro


Name: user_ritms


XML:



<?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_ritms_${jvar_guid}:${ref}"/>


<g:reference_decoration id="${jvar_n}" field="${ref}"


  onclick="showRelatedList('${ref}'); "


  title="${gs.getMessage('Show related ritms')}" image="images/icons/tasks.gifx"/>




<script>


// show related list


function showRelatedList(reference) {


try {


var displayValue = g_form.getDisplayBox(reference).value;


var title = 'Showing records related to: ' + displayValue;


var s = reference.split('.');


var referenceField = s[s.length - 1];


var query = referenceField + '=' + g_form.getValue(reference);




var gdw = new GlideModal('show_list');


gdw.setTitle(title);


gdw.setSize(750);


gdw.setPreference('table', 'sc_req_item_list');


gdw.setPreference('sysparm_query', query);


gdw.setPreference('title', 'A New Title');


gdw.render();


} catch (e) {


jslog('error showing related list');


jslog(e);


}


}




</script>


</j:jelly>



2. In your configure dictionary section of your desired field add this attribute


ref_contributions=user_ritms



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

5 REPLIES 5

Jaspal Singh
Mega Patron
Mega Patron

Hi Edwin,



You need to have UI Macro created for the same & then pass the UI Macro name to the attribute section of the field.



For instance UI Macro,user_show_incidents for incidents that appear next to caller field.


Prateek kumar
Mega Sage

Hello Edwin


This article should help you


Show related incidents


Navigate to system definition> UI macros


1. create a new UI macro


Name: user_ritms


XML:



<?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_ritms_${jvar_guid}:${ref}"/>


<g:reference_decoration id="${jvar_n}" field="${ref}"


  onclick="showRelatedList('${ref}'); "


  title="${gs.getMessage('Show related ritms')}" image="images/icons/tasks.gifx"/>




<script>


// show related list


function showRelatedList(reference) {


try {


var displayValue = g_form.getDisplayBox(reference).value;


var title = 'Showing records related to: ' + displayValue;


var s = reference.split('.');


var referenceField = s[s.length - 1];


var query = referenceField + '=' + g_form.getValue(reference);




var gdw = new GlideModal('show_list');


gdw.setTitle(title);


gdw.setSize(750);


gdw.setPreference('table', 'sc_req_item_list');


gdw.setPreference('sysparm_query', query);


gdw.setPreference('title', 'A New Title');


gdw.render();


} catch (e) {


jslog('error showing related list');


jslog(e);


}


}




</script>


</j:jelly>



2. In your configure dictionary section of your desired field add this attribute


ref_contributions=user_ritms



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Edwin Fuller
Tera Guru

Thanks, I've duplicated the show related incidents UI Macro and added it to my request field. Now I need to modify the script below to look for related Requested Items instead of incidents. Will I need to modify anything else or create anything else like a UI page? Also, I don't have the slightest clue yet about jelly writing hoping someone can start me off.



<?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="showRelatedIncidentList('${ref}'); "


  title="${gs.getMessage('Show related incidents')}" image="images/icons/tasks.gifx"/>




<script>


// show related list


// todo: should be part of the PopupWindow class


// todo: needs new stack name


function showRelatedIncidentList(reference) {


  var s = reference.split('.');


  var tableName = s[0];


  var referenceField = s[1];


 


jslog("Table name:   " + tableName);


jslog("Reference:     " + referenceField);




  var v = g_form.getValue(referenceField);




jslog("Value:             " + v);




  //var url =   tableName + '_list.do?';


  //url += '&amp;amp;';


  //url += 'sysparm_query=' + referenceField + '=' + v;




  //var w = getTopWindow();


  //w.popupOpenFocus(url, 'related_list',   950, 700, '', false, false);


 


  var gdw = new GlideDialogWindow('show_incident_list', false, 950, 700);


  gdw.setTitle('Related incidents');


  gdw.setPreference('table', 'incident_list');


  gdw.setPreference('sysparm_view', 'default');


  gdw.setPreference('sysparm_query', referenceField + '=' + v);


  gdw.render();


}




</script>


</j:jelly>


i have already edited that part in my script



Please mark my response as correct and helpful if it helped solved your question.
-Thanks