How to put an clickable email address in an alert in a client script?

snow_beginner
Mega Guru

Hi, 

So my requirement is that when someone is about to raise a data only change with a Configuration item that's fingerprinted in the last 10 days, it should not happen so the functionality I have put in is an alert which says you can't do that and to contact this team, but I need to provide their email address in the alert and I think it needs to be clickable so when clicked, it opens up a new email with that email in the sender. Here is the client script below.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

   
    if (g_form.getValue('type') == 'data_only') {
        var ga = new GlideAjax('LBGCheckCITaggedOrFingerprinted');
        ga.addParam('sysparm_name', 'checkCIDiscoveryMechanism');
        ga.addParam('sysparm_configVar', newValue);
        ga.getXML(HelloWorldParse);
    }


    function HelloWorldParse(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if(answer == 'yes'){
            alert('You are attempting to remove an active automated CMDB relationship.  This cannot be done via a Data Only Change.  If you require further guidance please email Technology Data Optimisation');
        }
    }
 
The bolded bit needs to be the email link. How would I do this?
 
Thanks!

 

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@snow_beginner 

javascript alert method doesn't support hyperlinks or any html tags

you should use g_form.addInfoMessage() and show the link

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar 

The link you posted shows how to put a link in a message, what about an email address that when clicked opens up the email. So when you click the word it opens up a new email with that address in the to field.

 

Is that possible to do?

Ankur Bawiskar
Tera Patron
Tera Patron

@snow_beginner 

this link has solution

How To Add A Hyperlink To An Info Message (addInfoMessage) In ServiceNow 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@snow_beginner 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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