How do i get the display value of reference field on UI page pop up?

Nowlearner
Kilo Guru

Hi,

I have a UI page which pops up when someone hits 'propose major incident' ui action on incident form. Below is how it looks like, i am trying to retrieve the display value of the 'application' selected but i just receive the sys id of it

 

find_real_file.png

Can someone help me here, below is the code of my ui page for reference field.

HTML:

<div class="form-group">
		<label class="col-sm-2 control-label" for="mim-propose-application">${gs.getMessage('What application(s) are experiencing impact?')}</label>
		<div class="col-sm-10">
			
		<g:evaluate>
  var UserDisplayValue = RP.getWindowProperties().get('UserDisplayValue');
  var UserValue = RP.getWindowProperties().get('UserValue');
</g:evaluate>			
			<g:ui_reference name="mim-propose-application" query="
nameSTARTSWITH*undocumented^ORinstall_status!=7^install_status!=21^sys_class_name!=u_enterprise_applications^u_category!=Business Element^sys_class_name!=u_cmdb_ci_user_groups^sys_class_name!=u_cmm_ciks^NQsys_class_name=u_enterprise_applications^install_status=1^EQ" table="cmdb_ci" displayValue="${UserDisplayValue}" value="${UserValue}"/>

 

Do i have to write something in the client script to retrieve the display value into worknotes of incident? I am just posting the below client script  part of ui page for reference

CLient script:

addLoadEvent(function() {
	(function(global) {
		var workNotes = $("mim-propose-work-notes");
		var businessImpact = $("mim-propose-business-impact");
		var workNotesWrapper = $('work-notes-wrapper');
		var proposeBtn = $('mim-propose-button');
		var impact = $('mim-propose-impact');
		var application = $('mim-propose-application');
		var customer = $('mim-propose-customer');
		var details = $('mim-propose-details');
		workNotes.focus();
		var dialog;
		if(!config.workspace) {
			dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");

          var currentWorkNotes = dialog.getPreference('WORK_NOTES');
          if(currentWorkNotes) {
              workNotes.value = currentWorkNotes;
              workNotesOnChange();
          }
          var currentBusinessImpact = dialog.getPreference('BUSINESS_IMPACT');
          if(currentBusinessImpact)
              businessImpact.value = currentBusinessImpact;
        }
		
		var currentimpact = dialog.getPreference('IMPACT');
		if(currentimpact)
		impact.value = currentimpact;
		
		var currentapplication = dialog.getPreference('APPLICATION');
		if(currentapplication)
		application.value = currentapplication;	
		
		var currentcustomer = dialog.getPreference('CUSTOMER');
		if(currentcustomer)
		customer.value = currentcustomer;
		
		var currentdetails = dialog.getPreference('DETAILS');
		if(currentdetails)
		details.value = currentdetails;
		
		
		function _debounce(func, wait, immediate) {
			var timeout;
			return function() {
				var context = this,
					args = arguments;
				var later = function() {
					timeout = null;
					if (!immediate) func.apply(context, args);
				};
				var callNow = immediate && !timeout;
				clearTimeout(timeout);
				timeout = setTimeout(later, wait);
				if (callNow) func.apply(context, args);
			};
		}

		function workNotesOnChange() {
			if (!workNotes.value.trim()) {
				workNotesWrapper.removeClassName('is-filled');
				proposeBtn.addClassName('disabled');
				proposeBtn.writeAttribute('aria-disabled', true);
			} else {
				workNotesWrapper.addClassName('is-filled');
				proposeBtn.removeClassName('disabled');
				proposeBtn.writeAttribute('aria-disabled', false);
			}
		}

		function propose() {
			if (!proposeBtn.hasClassName('disabled')) {
				var msg = getMessage("Proposed as major incident candidate");
				var notes = workNotes.value.trim();
				var bi = businessImpact.value.trim();
				var i = impact.value.trim();
				var a = application.value.trim();
				var c = customer.value.trim();
				var d = details.value.trim();
			
				if(!config.workspace) {
					g_form.getControl('work_notes').value = msg + "\n" + notes + "\n" + bi + "\n" + i + "\n" + c + "\n" + d + "\n" + "What application(s) are experiencing impact?" + "\n" +a;
					
					close();
					gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_propose');
				}else {
					iframeMsgHelper.confirm({
						msg: msg,
						workNotes: notes,
						businessImpact: bi
					});
				}
			}
		}

		function close() {
			if(!config.workspace)				dialog.destroy();
			else
				window.location.href = window.location.href + '&sysparm_next_pg=true';
		}
		global.proposeModal = {
			propose: propose,
			close: close,
			workNotesOnChange: _debounce(workNotesOnChange, 200) // Only execute when left idle for 200 ms
		};
	})(window);
});
1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hello,

Please see my reply here, in your duplicate other thread: https://community.servicenow.com/community?id=community_question&sys_id=7c8c825c1b367050ada243f6fe4b...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Thanks for the reply.


var UserValue = g_form.getDisplayBox('u_business_owner').value;

 

Using it in the UI Page like this:

<g:evaluate>
var UserValue = RP.getWindowProperties().get('uUserValue');
</g:evaluate>

<g:ui_reference name="user_name" table="sys_user" displayValue="${UserValue}"/>

 

I found this syntax from the post, but i am not sure where to put the first line of code "var UserValue = g_form.getDisplayBox('u_business_owner').value;" 

SHould i put this in the ui action?  I am trying to get the value displayed on a field from a Ui action pop up, i am not trying to get this value to populate on any incident form field. Just trying to post it in the work notes of the incident.

Can someone guide me?

 

Thanks for the reply.


var UserValue = g_form.getDisplayBox('u_business_owner').value;

 

Using it in the UI Page like this:

<g:evaluate>
var UserValue = RP.getWindowProperties().get('uUserValue');
</g:evaluate>

<g:ui_reference name="user_name" table="sys_user" displayValue="${UserValue}"/>

 

I found this syntax from the post, but i am not sure where to put the first line of code "var UserValue = g_form.getDisplayBox('u_business_owner').value;" 

SHould i put this in the ui action?  I am trying to get the value displayed on a field from a Ui action pop up, i am not trying to get this value to populate on any incident form field. Just trying to post it in the work notes of the incident.

Can someone guide me?

 

Allen Andreas
Administrator
Administrator

Hello,

Please see my reply here, in your duplicate other thread: https://community.servicenow.com/community?id=community_question&sys_id=7c8c825c1b367050ada243f6fe4b...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!