Reference qualifier and UI Macro

Saisree Kota
Tera Contributor

Hi All,

 

There is a Reference Field where i have a written a script include with Reference Qualifier to filter some records on the table and created a new UI Macro which should display the records without the filters. Now when i click on Newly created Macro button it is displaying the same results as of Refernce Qualifier.

 

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">
   <j:set var="jvar_n" value="show_all_tasks_${ref}"/>
   <span id="${jvar_n}" onclick="showAllTasks('${ref}', '${jvar_n}')" title="Select From All Tasks" alt="Select From All Tasks" tabindex="0" class="btn btn-default icon-list">
      <span class="sr-only">Show All Tasks</span>
   </span>
 
<script>
// show related list
function showAllTasks(reference, id) {
try {
 
var thefield = 'task'; //Identify the reference field this should be attached to.         
var thetable = 'task_time_worked'; //This gets whatever table you are on.
 
var lookupfield = 'lookup.'+ thetable + '.' + thefield; //Creates the lookup or reference field ID.  
var pinclookup = $(lookupfield); 
 
if (pinclookup){  
var thetarget = thetable + '.' + thefield;  
 
            var url = "&amp;amp;"+g_form.getValue('task');  
//This line builds up the URL filter.  Build this just like a reference qualifier.  
 
var refurl = reflistOpenUrl(thetarget, thetarget, thefield, 'task', 'null', 'false', '');  
var refurlquery = refurl+url ; 
popupOpenStandard(refurlquery, 'lookup'); 
}
 
 
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
 
</script>
</j:jelly> 

  

 

Can someone help me with the changes to make the macro to display all the records.

2 REPLIES 2

Ratnakar7
Mega Sage
Mega Sage

Hi @Saisree Kota ,

 

It appears that you have a Reference Field with a Reference Qualifier that filters records, and you've created a UI Macro to display records without these filters. However, when you click the Macro button, it still displays the filtered results. To display all records using the UI Macro, you need to make some modifications to your code.

 

Here's how you can modify your UI Macro to display all records:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
   <j:set var="jvar_n" value="show_all_tasks_${ref}"/>
   <span id="${jvar_n}" onclick="showAllTasks('${ref}', '${jvar_n}')" title="Select From All Tasks" alt="Select From All Tasks" tabindex="0" class="btn btn-default icon-list">
      <span class="sr-only">Show All Tasks</span>
   </span>
 
   <script>
      // Show all records without filtering
      function showAllTasks(reference, id) {
         try {
            var thefield = 'task'; // Identify the reference field this should be attached to.
            var thetable = 'task_time_worked'; // This gets whatever table you are on.
            var lookupfield = 'lookup.' + thetable + '.' + thefield; // Creates the lookup or reference field ID.
            var pinclookup = $(lookupfield);
 
            if (pinclookup) {
               // Clear any reference qualifier
               g_form.setRefQual(''); // This line clears the reference qualifier
 
               // Trigger a reload of the reference field
               g_form.getReference(thefield); // This line reloads the reference field
 
               // Optionally, you can close the popup or modal that opened the UI Macro
               var frameWindow = getFrameWindow(window);
               if (frameWindow) {
                  frameWindow.g_modalStack.closeLast();
               }
            }
         } catch (e) {
            jslog('error showing all records');
            jslog(e);
         }
      }
 
      // Helper function to get the frame window in case the UI Macro is opened in a modal or popup
      function getFrameWindow(win) {
         try {
            if (win === top) {
               return null;
            }
            if (win.g_form) {
               return win;
            }
            return getFrameWindow(win.parent);
         } catch (e) {
            return null;
         }
      }
   </script>
</j:jelly>

 

Thanks,

Ratnakar

Hi @Ratnakar7 ,

 

Thanks for your help.

Modified the script as above. Now when i click on the Macro Button it is not opening any window it remains on the same page.