The CreatorCon Call for Content is officially open! Get started here.

Need a help on notification

William08
Tera Contributor

Hi all,

 

We need a help on approval notification which is sent to now mobile app, currently in the notification we have all the variables shown but we need to restrict the variable[hide variables] if it has empty values or if checkbox is false. Please help!!

 

Thanks in advance.

5 REPLIES 5

Anand Kumar P
Giga Patron

Hi @William08 ,

You can write email script and by sending values from notification to email script and manipulate in email script and return to notification

(function runMailScript(current, template, email, email_action, event) {
    if (current.getTableName() == 'incident') {
        template.print('<div><p class="Approval">Approval Details:</p>');

        if (current.caller_id.getDisplayValue()) {
            template.print('<p class="normal">Caller: ' + current.caller_id.getDisplayValue() + '</p>');
        }
        if (current.caller_id.email) {
            template.print('<p class="normal">Email: ' + current.caller_id.email + '</p>');
        }
        if (current.description) {
            template.print('<p class="normal">Description: ' + current.description + '</p>');
        }

        template.print('</div>');
    }
})();
In notification body call email script-${mail_script:yourmailscriptname}

Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

Hi @Anand Kumar P ,

 

Can we do this for push notifications too?

Ankur Bawiskar
Tera Patron
Tera Patron

@William08 

Please share screenshot where is this required

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

@William08 

is this for normal email notification? if yes then please share how the variables are currently included in email body.

Is it via email script or included directly?

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