- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2024 11:13 PM
Hi, I was learning about UI macros and my requirement is to add Assign me icon in front of caller field so that whenever user clicks on that icon, he can assign himself as caller. I have created following UI macro and added it to the dictionary level on caller field.
After adding this I was not able to see that macro on caller field in new form. Kindly help me with the functionality.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 01:35 PM
I have found the solution. Above scripts were missing the main functionality. The exact solution should be that whenever the UI macro is clicked it should call a function which should contain the parameter as the field name. With the below code I was able to perform the functionality.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<span id="add_me_button" class="btn btn-default icon-user-add" tabindex="0" title="Add me" onclick="addMe('caller_id')">
<span class="sr-only">Add me</span>
</span>
<script>
function addMe(reference) {
var userID = g_user.userID;
g_form.setValue(reference, userID);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2024 12:17 PM
Hi @kaushiki berter ,
Please refer below thread:
https://www.servicenow.com/community/developer-articles/ui-macros-secnario-s/ta-p/2323143
Plz mark my solution as Accept, If you find it helpful.
Thanks & Regards,
Sumanth meda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 01:35 PM
I have found the solution. Above scripts were missing the main functionality. The exact solution should be that whenever the UI macro is clicked it should call a function which should contain the parameter as the field name. With the below code I was able to perform the functionality.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<span id="add_me_button" class="btn btn-default icon-user-add" tabindex="0" title="Add me" onclick="addMe('caller_id')">
<span class="sr-only">Add me</span>
</span>
<script>
function addMe(reference) {
var userID = g_user.userID;
g_form.setValue(reference, userID);
}
</script>
</j:jelly>