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.

to restrict the mail address using inbound

tGhadage
Tera Contributor

Hi Guys,

 

I have a requirement where email address is from test@test.com so it should not create an incident and another mail should be send to the user with the " subject : mentioned email address is no longer active ".

 

any help would be fine Thanks!!! 

4 REPLIES 4

Jaspal Singh
Mega Patron
Mega Patron

Hi,

So what is that you have tried and where are you stuck?

hi @Jaspal Singh ,

Have created an inbound action but it's not working as its creating the incident.

Can you share here the logic once.

(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {

    // Implement email action here
	if(email.from.indexOf('Your email ID to check')<-1){ // Replace your Email Address to exclue here
    gs.include('validators');

    if (current.getTableName() == "incident" && current.state != "7" && current.state != "8") {

        var gr = current;

        gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

        gr.update();
    } else if (current.getTableName() == "incident" && (email.recipients.toLowerCase().indexOf('test@mail.com') > -1) && (current.state == "7" || current.state == "8")) {

        var gr1 = current;

        var gr2 = new GlideRecord("incident");
        gr2.initialize();
        gr2.setValue("caller_id", gr1.getValue("caller_id"));
        gr2.setValue("location", gr1.getValue("location"));
        gr2.setValue("business_service", gr1.getValue("business_service"));
        gr2.setValue("category", gr1.getValue("category"));
        gr2.setValue("subcategory", gr1.getValue("subcategory"));
        gr2.setValue("short_description", gr1.getValue("short_description"));
        gr2.setValue("description", gr1.getValue("description"));
        gr2.setValue("parent", gr1.getValue("sys_id"));
        gr2.setValue("contact_type", "email");
        gr2.work_notes = "This incident is created after email reply to closed incident number " + gr1.number + ":" + "\n\n" + current.work_notes.getJournalEntry(-1);
        gr2.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
        gr2.insert();
    }
	}

})(current, event, email, logger, classifier); 

this is the inbound action