MS Teams Ui macro for Requested For field SCTASK, REQ, RITM

rajesh29
Tera Expert

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;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>

1 ACCEPTED SOLUTION

Thank you for your Help,

this is what exactly we looking. this might be working all TASK, REQ, RITM.

Thanks,

Rajesh Bandila.

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

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;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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you for your Help,

this is what exactly we looking. this might be working all TASK, REQ, RITM.

Thanks,

Rajesh Bandila.

@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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar 

 

yes, your Script is working perfectly.

once again thank you!