UI Macro to populate Location field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 12:52 PM
Hello everyone,
I am trying to create a UI Macro, which when clicked opens a window showing the list of active locations in the location field. Location is already having a reference qualifier which shows only active location when we click lookup icon.
User can also select the inactive locations if they want to on the incident form because of which I need to create a UI Macro which will display next to Location field on the incident form.
I have gotten so far - I have the Macro button appearing where I want, and I have figured out that I need to use reflistOpenUrl and popOpenStandard functions. However I am struggling with creating the URL. UI Macro which when clicked, opens a window with the filter condition -'All->Active=true' which give all the active location, but when i remove the filter 'Active=true' , it is not showing all the locations including the inactive ones.
I think, UI Macro is taking additional reference qualifier into consideration and showing only active locations.
How can I solve this issue. If anyone could give me any pointers on how to do that, I'd be grateful.
Adding the snippet of the code.
Thanks in advance for any help.
Rooma Wakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 01:08 PM
I don't understand why don't you just remove the reference qualifier?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 04:09 AM
Hi,
In the lookup search of the location field, we need to show only active location to the users that is why we can't remove it.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2024 02:47 PM
Hi @Rooma1 ,
Create a new UI page
Name: location_info_ui_page
Script:
<?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_loc_info_present" jelly="true">
var loc_info_present = RP.getParameterValue('sysparm_loc_info_present');
loc_info_present;
</g:evaluate>
<g:evaluate var="jvar_loc_name" jelly="true">
var loc_name = RP.getParameterValue('sysparm_loc_name');
loc_name;
</g:evaluate>
<g:evaluate var="jvar_country" jelly="true">
var country = RP.getParameterValue('sysparm_country');
country;
</g:evaluate>
<g:evaluate var="jvar_city" jelly="true">
var city = RP.getParameterValue('sysparm_city');
city;
</g:evaluate>
<j:if test="${jvar_loc_info_present == 'true'}">
<div>
<b>Location name:</b> <p id="loc_name">${jvar_loc_name}</p>
<b>Country:</b> <p id="country">${jvar_country}</p>
<b>City:</b> <p id="city">${jvar_city}</p>
</div>
</j:if>
<j:if test="${jvar_loc_info_present == 'false'}">
<div>
Location information for the caller selected in not found.
</div>
</j:if>
</j:jelly>
4. Update the script of "location_button" ui macro as below
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<button type="button" onclick="showLocInfo()">Show location info</button>
<script type="text/javascript">
function showLocInfo(){
var ga = new GlideAjax('LocationUtil');
ga.addParam('sysparm_name', 'getLocationInfo');
ga.addParam('sysparm_caller_id', g_form.getValue("caller_id"));
ga.getXML(showResponse);
}
function showResponse(resp){
var answer = resp.responseXML.documentElement.getAttribute("answer");
var gm = new GlideModal("location_info_ui_page");
gm.setTitle("Caller's location information");
gm.setWidth(400);
if(answer){
answer = JSON.parse(answer);
gm.setPreference('sysparm_loc_name', answer.loc_name);
gm.setPreference('sysparm_country', answer.country);
gm.setPreference('sysparm_city', answer.city);
gm.setPreference('sysparm_loc_info_present', 'true');
}else{
gm.setPreference('sysparm_loc_info_present', 'false');
}
gm.render();
}
</script>
</j:jelly>
Result:
When location info present:
When location info not present
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2024 04:11 AM
Hi Sumanth,
Sorry to say but this solution isn't matching to my requirement. I need to solution to build the URL so that the pop up window can show all the locations after removing the filter condition -"Active=True".
I don't want to search location based on the caller field.
Thanks,
Rooma