Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Using if statement to detect empty "Long text" field

Topic Labels: Scripting extentions
Solved
Jump to Solution
1171 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Jordan_Bass
5 - Automation Enthusiast
5 - Automation Enthusiast

How do I test for an empty Message field when it’s a “Long text” type?

This code does not work…

let strReplyStatus = '';
if (rsReply.getCellValue('Message') === '') {
    strReplyStatus = 'Empty';
};
if (rsReply.getCellValue('Message') == '') {
    strReplyStatus = 'Empty';
};
1 Solution

Accepted Solutions
Jordan_Bass
5 - Automation Enthusiast
5 - Automation Enthusiast

This code works…

if (rsReply.getCellValue('Message') === null) {
    strReplyStatus = 'Empty';
};

See Solution in Thread

2 Replies 2
Jordan_Bass
5 - Automation Enthusiast
5 - Automation Enthusiast

This code works…

if (rsReply.getCellValue('Message') === null) {
    strReplyStatus = 'Empty';
};

Alternatively:

if(rs.Reply.getCellValue('Message').length===0){
//do whatever
}

Or, if you want to get cute:

if(!rs.Reply.getCellValueAsString('Message').length>0){
//do whatever
}

Checking for null values is a pretty yolo thing to do in JavaScript AFAIK, and just going for the length check is usually better in terms of performance.