Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

Using if statement to detect empty "Long text" field

Topic Labels: Scripting extentions
Solved
Jump to Solution
409 2
cancel
Showing results for 
Search instead for 
Did you mean: 

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.