How to display related records with UI Macro like in Incident form

Armin Heinlein1
Giga Expert

Hi,

I am still trying to improve my very first scoped application and would like to show related records for a member. Same way how it is done in the incident form. So I created the reference contribution to the table that contains the records I want to display. Member is a referenced field to the member table.

find_real_file.png

find_real_file.png

Then I created a UI Macro called member_show_requests. Yes, I copied the user_show_incidents UI macro because I thought it is a similar request.

But I guess I tried to make my life too easy. It is not working.

What am I missing?

I spend a lot of time trying to get this to work but don't know where to look.

--------------------------------------------------------------

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

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

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

            title="${gs.getMessage('Show related records')}" 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', 'my_records_list');

                      gdw.setPreference('sysparm_query', query);

                      gdw.setPreference('title', 'Related records');

                      gdw.render();

            } catch (e) {

                      jslog('error showing related list');

                      jslog(e);

            }

}

</script>

</j:jelly>

8 REPLIES 8

Yes, I think that was all that was changed.   There should be no system properties just dictionary attributes.



A couple things to try:



Do you see any errors on the console log since the catch block is writing them there?   Any broken client javascript could cause this to fail.



Can you change the name of the function to something you know is unique?   If another decorator has a 'showRelatedList' function that might break things.   Though I would expect that to be after it renders the icon.   My test case wasn't an issue because there was only 1 field on the form.



If that doesn't work, can you test with a shorter table name and/or shorter ui macro name?   Maybe the length of the table name or macro is causing an issue.



Make sure there is a value in the member field.   The icon doesn't show up until there is.



Beyond that, I'm not sure as I can't reproduce the issue.


Hi Joe,



I am tried your suggestion and wasn't successful.


I guess I put this on ice for a while.



Armin


Rajasekhar Kol2
Kilo Explorer

Hello Armin,

were you able to find the solution for this problem, If so please let me know

 

Dana2
Tera Expert

Hi,

You should try changing the name of your function, as 'showRelatedList' is already used by 'user_show_incidents' UI Macro.

Oh, and also after creating a UI Macro you should remember to add the attribute to the dictionary field: ref_contributions=<your-ui-macro>. You can add multiple contributions and separate them by ';'.

 

Dana