- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 06:53 AM - edited 09-09-2024 06:56 AM
Hi Team,
I have created a UI action with 'cmn-location' table. when selecting the any location from the list, it was shows as the details of the location, but i need populate selected location into the 'location' field. i tried this script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 03:13 AM
<?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_location_${ref}"/>
<span id="${jvar_n}" onclick="showAllLocations('${ref}', '${jvar_n}')" title="Select From All Locations" alt="Select From All Locations" tabindex="0" class="btn btn-default icon-list">
<span class="sr-only">Show All Locations</span>
</span>
<script>
// show related list
function showAllLocations(reference, id) {
try {
var tableField = reference;
var tableFieldSplit = reference.toString().split(".");
var elementID = 'lookup.' + reference.toString();
//document.getElementById(elementID).style.display="none";
var thefield = tableFieldSplit[1]; //Identify the reference field this should be attached to.
var thetable = g_form.getTableName(); //This gets whatever table you are on.
var lookupfield = elementID; //Creates the lookup or reference field ID.
var pinclookup = $(lookupfield);
if (pinclookup){
var thetarget = thetable + '.' + thefield;
var url = '$[AMP]'+'sysparm_query=city=York';
//Here you create some variables to get the values of the fields you want in your custom filter.
var theci = g_form.getValue(thefield); //Get Value of field to pass into query
var taskid = g_form.getUniqueValue(); //Get current sys_id to exclude it in the query
//This line builds up the URL filter. Build this just like a reference qualifier.
var refurl = reflistOpenUrl(thetarget, thetarget, thefield, 'cmn_location', 'null', 'false', '');
var refurlquery = refurl + url;
popupOpenStandard(refurlquery, 'lookup');
}
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 09:37 AM
Hi @Kusuma Sai Try below code
function getLocations() {
var loc = new GlideModal('show_list');
loc.setPreference('table', 'cmn_location');
loc.setPreference('sys_id', g_form.getUniqueValue());
loc.setPreference('callback', 'onLocationSelected');
loc.render();
}
function onLocationSelected(selectedRecord) {
var locationSysId = selectedRecord.sys_id; // or whatever property you're using
g_form.setValue('location', locationSysId);
getLocations();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2024 09:52 AM
Hi Sid,
when i am click on the UI Action button shows as 'Record not found' popup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 03:13 AM
<?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_location_${ref}"/>
<span id="${jvar_n}" onclick="showAllLocations('${ref}', '${jvar_n}')" title="Select From All Locations" alt="Select From All Locations" tabindex="0" class="btn btn-default icon-list">
<span class="sr-only">Show All Locations</span>
</span>
<script>
// show related list
function showAllLocations(reference, id) {
try {
var tableField = reference;
var tableFieldSplit = reference.toString().split(".");
var elementID = 'lookup.' + reference.toString();
//document.getElementById(elementID).style.display="none";
var thefield = tableFieldSplit[1]; //Identify the reference field this should be attached to.
var thetable = g_form.getTableName(); //This gets whatever table you are on.
var lookupfield = elementID; //Creates the lookup or reference field ID.
var pinclookup = $(lookupfield);
if (pinclookup){
var thetarget = thetable + '.' + thefield;
var url = '$[AMP]'+'sysparm_query=city=York';
//Here you create some variables to get the values of the fields you want in your custom filter.
var theci = g_form.getValue(thefield); //Get Value of field to pass into query
var taskid = g_form.getUniqueValue(); //Get current sys_id to exclude it in the query
//This line builds up the URL filter. Build this just like a reference qualifier.
var refurl = reflistOpenUrl(thetarget, thetarget, thefield, 'cmn_location', 'null', 'false', '');
var refurlquery = refurl + url;
popupOpenStandard(refurlquery, 'lookup');
}
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
</script>
</j:jelly>