Skip to main content

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

};

This code works…



if (rsReply.getCellValue('Message') === null) {

strReplyStatus = 'Empty';

};


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.


Reply