Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to add domain name to body of email

saikrishnag3019
Tera Contributor

https://www.servicenow.com/community/developer-forum/how-to-add-a-domain-to-the-body-of-an-email/m-p...

 

With the above script im able to get domain URL and ID, but I need domain name, is it possible? when i use domain display name its giving message as un defined

1 REPLY 1

Amitoj Wadhera
Kilo Sage

Hi @saikrishnag3019 ,

 

Please find below the code:

var uri = gs.getProperty("glide.servlet.uri");
var name = gs.getProperty("instance_name");
var iid = gs.getProperty("instance_id");

function extractRootDomain(uri) {
    var domain;
    if (uri.indexOf("://") > -1) {
        domain = uri.split('/')[2];
    } else {
        domain = uri.split('/')[0];
    }
    domain = domain.split(':')[0];
    var domainParts = domain.split('.');
    if (domainParts.length > 2) {
        domain = domainParts.slice(-2).join('.');
    }
    return domain;
}
var rootDomain = extractRootDomain(uri);
template.print(rootDomain); 

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Thanks,

Amitoj Wadhera