Notes field – how to test if empty

Viewing 2 reply threads
  • Author
    Posts
  • July 17, 2020 at 3:19 AM #41335

    Victor Warner
    Participant

    I would like to combine a Notes field with other in a script, but if the Notes field is empty I wish to display just the other fields.

    I have created a test database with a test script as follows:

    var notes_id = 'fld-9d8543d9d39f409194349c1a855d7728';
    var notes = record.getFieldValue('fld-9d8543d9d39f409194349c1a855d7728');
    
    var new_work_address_id = 'fld-943ab25fd0de42e7b8d1e5487c6a358b';
    var new_work_address = record.getFieldValue('fld-943ab25fd0de42e7b8d1e5487c6a358b');
    
    if (notes == "") {
    
    result = new_work_address
    
    } else {
    
    result = new_work_address + "\n\n" + notes;
    
    }
    
    result

    But if the Notes field is empty the result is the content of new_work_address plus plus the word ‘undefined’

    Is there a way to test for whether a Notes field is empty?

    July 17, 2020 at 8:16 PM #41355

    Brendan
    Keymaster

    Hi Victor

    if (notes == undefined) {
    
    }
    

    or

    if (notes == null) {
    
    }
    

    For example:

    function Check_Notes() {
    
    	var notes = record.getFieldValue('fld-d2953777d8f5442d8d4d5a07f93e9c0e');
    	if (notes == null) {
    		return "no note value";
    	} else {
    		return "note: " + notes;
    	}
    	
    }
    
    Check_Notes();
    July 23, 2020 at 10:37 AM #41479

    Victor Warner
    Participant

    Brendan,

    Thank you for the information.

Viewing 2 reply threads

You must be logged in to reply to this topic.