UI macro not working

Sundar16
Tera Contributor

Hi All,

I am trying to change the UI macro for the Dependency View of the Incident, Change, Requested Item etc..

I can find the UI macro that is related to the same - task_show_ci_map (OOTB)

Here is my system setup, I have an application and a service map entry for the same. When an application is selected and if the user click on the Dependency view icon (which invokes the macro), I want them to see the Service Map of the application instead of the application entry. I cannot restrict the class in the reference qualifier because of business reasons and I want them to see the application dependencies via the service map. I tried modifying the "showBSMMap" function as specified below, however its not working. If I hard code the service map entry it is working. Below are the 2 versions I tried, which is not working. In version 1 if I hard code sys id it is working, version 2 it is entering only in the first loop.

Version 1 :
        // Construct a link to the correct version of BSM and open it
        function showBSMMap(sys_id, fieldName) {
                    var grMap = new GlideRecord('cmdb_ci_service');
                        if(grMap.get('duplicate_of',sys_id))
                        {
                            sys_id=grMap.sys_id;                        
                        }
            var url = '';

            // When using NGBSM, use a simplified link
            url += '$ngbsm.do?id=' + sys_id;
            url += '&';
            url += 'serviceView=' + '$[jvar_ngbsm_service]';
            url += '&';
            url += 'sysparm_nostack=true'; //PRB675289 - support 'back' correctly
            url += '&';
            url += 'fromTask=' + g_form.getUniqueValue();

            // Open the map in a new window and focus it
            g_navigation.open(url, 'super_bsm_map');
        }
 
Version 2 : 
 

        // Construct a link to the correct version of BSM and open it
        function showBSMMap(sys_id, fieldName) {
        var gr = new GlideRecord('cmdb_ci_appl');
if(gr.get(sys_id))
{
var grMap = new GlideRecord('cmdb_ci_service_discovered');
grMap.addEncodedQuery('XXX='+gr.XXX);
grMap.query();
if(grMap.next())
{
sys_id=grMap.sys_id;
}
}
            var url = '';

            // When using NGBSM, use a simplified link
            url += '$ngbsm.do?id=' + sys_id;
            url += '&';
            url += 'serviceView=' + '$[jvar_ngbsm_service]';
            url += '&';
            url += 'sysparm_nostack=true'; //PRB675289 - support 'back' correctly
            url += '&';
            url += 'fromTask=' + g_form.getUniqueValue();

            // Open the map in a new window and focus it
            g_navigation.open(url, 'super_bsm_map');
        }
 
Can anyone find any issue in the above versions of the code. Any suggestions is appreciated.
 
Regards,
Sundar
1 REPLY 1

Abbas_5
Tera Sage
Tera Sage

Hello @Sundar16,

Please refer to the link below:
https://www.servicenow.com/community/developer-forum/ui-macro-not-working-properly/m-p/1829698

 

If it is helpful, please mark it as helpful and accept the correct solution.

Thanks & Regards,

Abbas Shaik