Skip to main content
Solved

Using if statement to detect empty "Long text" field

  • June 11, 2021
  • 2 replies
  • 38 views

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';
};

Best answer by Jordan_Bass

This code works…

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

2 replies

  • Author
  • New Participant
  • 2 replies
  • Answer
  • June 11, 2021

This code works…

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

Forum|alt.badge.img+17

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.