how to get the current record sys_id in UI macro's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 05:10 AM
Want to get the current record sys_id in UI macros. that value should be passed to onclick function as 2nd parameter .Can anyone help me on this issue. i have tried $[current.sys_id] ..but it is not working
<?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_ref1" value="ref_image_macros_${ref}"/>
<a id="${jvar_ref1}">
<img border="0" src="ref_record.pngx" width ="13" height="13" title="${gs.getMessage('Reference Record Info')}" onclick="displayRefRecord('${ref}');"/>
</a>
<script>
function displayRefRecord(reference) {
//alert("kilk");
//alert("working"+reference);
var fieldLabel = reference.split('.');
var referenceField = fieldLabel[1];
//alert("the label of the field--->"+referenceField);
//alert("sys_id-->"+g_form.getUniqueValue()+e);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 11:16 PM
I found out the solution...use g_form
<?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>
gs.log("current sys_id--->"+${current.sys_id});
</g:evaluate>
<j:set var="jvar_ref1" value="ref_image_macros_${ref}"/>
<a id="${jvar_ref1}">
<img border="0" src="ref_record.pngx" width ="13" height="13" title="${gs.getMessage('Reference Record Info')}" onclick="displayRefRecord('${ref}');"/>
</a>
<script>
function displayRefRecord(reference) {
alert("kilk");
//alert("working"+reference);
var fieldLabel = reference.split('.');
var referenceField = fieldLabel[1];
var v = g_form.getValue(referenceField);
alert("vvvvvv------>"+ v);
var u =g_form.getUniqueValue();
alert("uuuuuuuu-->"+u);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 11:32 PM
Hi Akila,
Is your script working and fetching the correct sys_id?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2016 02:11 AM
yes Ankur,
g_form.getValue(referenceField) is retrieving the sys_id of the reference field record
g_form.getUniqueValue() is retrieving the sys_id of the incident where the reference field is presented.
mark correct if it is useful:)