1

Hi I need help on of my req in which i want some fields from Salesforce server to display in the LWC component on the basis of it i want to show one message in the child component,

If there is no data from the server side from wire method then need to pass a message to the child component.

 wire(try, { cID: '$cID' }) tre(result) {


            this.righty= result;

        }

if there is no data in the result i want to pass the value to the child component

<child-comp for-null ={righty}></child-comp>
  • Use throw new AuraHandledException('ERROR MSG'); IN APEX CLASS WHEN LIST EMPTY OR NULL . RETURN THIS. IT WILL SHOW ERROR WHAT YOU WANT . – Rijwandeltax May 15 at 14:48
0

you could try the below approach while using wire. If the data is received from the server then pass the same to child else in the error block pass some relevant message.

 @wire(getRecord, {
        recordId: '$workorderid',
        fields: FIELDS
    })
    workOrderData({
        error,
        data
    }) {
        if (data) {

            this.dataToChild=data

        } else if (error) {
           this.dataToChild='No data';

            this.handleError(error);
        }
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.