How to Hide a field in email notification?

Buddy 1
Tera Contributor

I have created a email notification script in parent table and when i tried to add or remove any variable, it is reflecting in all email notification (child table). But when the child table do not contain the variable which i newly added is showing as "undefined" in notification.

I don't want this to be happen. How to display a particular variable when condition satisfies.

for example:

1. i have "number" and "contact" variable  in email script which is created under parent table .

2. But i newly add "description" variable which is not present in all child table form , so will be show "undefined"

3. Basically i want to see "description" variable only based on condition (only when form contain the field and if there is not field found in case/incident created ,then it should be hidden rather than showing as "undefined")

How to achieve this, Can someone help me on this.

Thanks!

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Hi Buddy,

For normal fields we can use hasField() method to confirm if the field exist but it doesn't work for variables so what you can do is, in the email script try something like below

if (current.variables.var_name) {
        // The variable exists and is not null
} else {
        // The variable does not exist
}

Reference: script to check if a variable exists

Please mark this helpful/correct, if applicable.

Regards,

Muhammad

Regards,
Muhammad

View solution in original post

3 REPLIES 3

MrMuhammad
Giga Sage

Hi Buddy,

For normal fields we can use hasField() method to confirm if the field exist but it doesn't work for variables so what you can do is, in the email script try something like below

if (current.variables.var_name) {
        // The variable exists and is not null
} else {
        // The variable does not exist
}

Reference: script to check if a variable exists

Please mark this helpful/correct, if applicable.

Regards,

Muhammad

Regards,
Muhammad

@Muhammad,

The above code is working fine but the values in that field is not displaying in email notification.

How to display the value entered in that field.

Thanks!

 

Aman Kumar S
Kilo Patron

Hi,

You can utilize email script to validate if a value is empty or not:

Notification Email Scripts

Best Regards
Aman Kumar