0

Hello everybody I am currently working on a Flow that receives the Id from the record where the LWC action is and pass it to the LWC.

The LWC is a form that shows some lightning-input and lightning-comboboxes and some of this lightning-input are empty so the user can fill them, but there are other lightning-input that I want to default show the value of the name and other fields from the record.

And also I want that every time the user clicks in the action button to show the Form with the populated fields I am troubling.

So in my apex class I created the next wrapper to return it to the LWC:

@AuraEnabled(cacheable= True)
 public static WraperSObject getInformation(Id recordIdFlow){

MySObject information = new MySObject();
information = [SELECT Id, Name FROM MySObject WHERE Id =: recordIdFlow];

WraperSObject wrapperPS = new WraperSObject();
wrapperPS.name = information.Name;
return wrapperPS;
}
public class WraperSObject{
@AuraEnabled public String id{get;set;}
@AuraEnabled public String name{get;set;}
}

And in my .js I have the next code:

cups; //variable where I want to put the value that comes from the wrapper.
wiredRecord;
@wire(getInformation,{recordIdFlow: 'recordId'})
wiredInfo(result){
this.wiredRecord = result;
console.log('information from wrapper'+ result);
//dont know how to assign the value from the wrapper in the js variable
}

And in my .html the field is this:

<lightning-input type="text"  label="CUPS" max-length="22" name="cups"></lightning-input>

Could anybody help me?

Thanks

1 Answer 1

0

You can access wrapper data from 2 ways

1)if you are storing wrapper data in this.wiredRecord variable then you can access like this

this.wiredRecord.data.name

  1. Or you can use like this as well
    @wire(getPuntoSuministro,{recordIdPuntoSuministro: '$recordId'})
    wiredPuntosuminsitroInfo({data,error}){
        if(data){
            this.wiredRecord = data;
        }
        else if(error){
            console.log(error);
        }
    }

then you can access data like

this.wiredRecord.name

<lightning-input type="text" label="CUPS" max-length="22" value={this.wiredRecord.name} required name="cups" onchange={handleCups}></lightning-input>

You must log in to answer this question.