- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 11:08 PM
Hello everyone,
I have created teams Ui macro For Requested For field in Request table. that might be working as expected in SCTASK. but the Ui macro(teams icon) is visible in REQ and RITM as well, but it is not working REQ and RITM.
I need to work ui macro in RITM and REQ as well. how to achieve this?
please see the below code for your reference. Thanks in advance.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<a> <img src="TeamsChat.png" width="25" height="25" onClick="InvokeRequestor('${ref}')"></img></a>
<script>
function InvokeRequestor(reference) {
var prefix = 'https://teams.microsoft.com/l/chat/0/0?users=';
var firstname = g_form.getReference('request_item.request.requested_for').first_name;
var user = g_form.getReference('request_item.request.requested_for').email;
var subject = '&amp;message=Hi ' + firstname + ', this is regarding your ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');
var w = getTopWindow();
var url = prefix + user + subject;
w.open(url);
}
</script></j:jelly>
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 05:16 AM
Thank you for your Help,
this is what exactly we looking. this might be working all TASK, REQ, RITM.
Thanks,
Rajesh Bandila.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2022 11:16 PM
Hi,
so you are saying same UI macro should be used for RITM, REQ and SCTASK and it should determine the current table and show accordingly?
if yes then do this
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<a> <img src="TeamsChat.png" width="25" height="25" onClick="InvokeRequestor('${ref}')"></img></a>
<script>
function InvokeRequestor(reference) {
var prefix = 'https://teams.microsoft.com/l/chat/0/0?users=';
var tableName = g_form.getTableName();
var firstname;
var user;
if(tableName == 'sc_task'){
firstname = g_form.getReference('request_item.request.requested_for').first_name;
user = g_form.getReference('request_item.request.requested_for').email;
}
else if(tableName == 'sc_req_item'){
firstname = g_form.getReference('request.requested_for').first_name;
user = g_form.getReference('request.requested_for').email;
}
else{
firstname = g_form.getReference('requested_for').first_name;
user = g_form.getReference('requested_for').email;
}
var subject = '&amp;message=Hi ' + firstname + ', this is regarding your ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');
var w = getTopWindow();
var url = prefix + user + subject;
w.open(url);
}
</script></j:jelly>
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
‎03-29-2022 05:16 AM
Thank you for your Help,
this is what exactly we looking. this might be working all TASK, REQ, RITM.
Thanks,
Rajesh Bandila.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2022 04:00 AM
@rajesh
Did you marked your own response as correct?
Would you mind marking my response as correct if my script worked for you.
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
‎04-07-2022 05:01 AM
yes, your Script is working perfectly.
once again thank you!