0

I am creating one UI which populate values from js getters. But I am getting null text in UI when the field is empty in UI.

@wire(..)
case;
 get contactName() {
        return `${getFieldValue(this.case.data, Contact_First_NAME)} ${getFieldValue(this.case.data, 
                  Contact_Last_Name)}`;
      }

HTML UI>

<div> {contactName} </div>

** this is showing below outout if suppose first name is blank in last name is "Test" Output: nullTest****

How to handle this?

1 Answer 1

2

Try this.

get contactName() { 
    return `${ getFieldValue(this.case.data, Contact_First_NAME) || "" } ${ getFieldValue(this.case.data,  Contact_Last_Name) || "" }`;
}
4
  • can u pls tell me why this has to handle explicitly?
    – Raj SF
    Commented Feb 4, 2021 at 10:05
  • @AMS Well, that's the way getFieldValue API is written. If value does not exist, getFieldValue returns null.
    – Jay Rathod
    Commented Feb 4, 2021 at 14:25
  • @AMS, please mark the answer as correct, if it helped you.
    – Jay Rathod
    Commented Feb 4, 2021 at 14:25
  • Thanks!!!!!!!!!
    – Raj SF
    Commented Feb 4, 2021 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .