0

I'm new with lwc. I'm using a recordeditform in which I render fields retrieved in the js controller importing them.

JS:

import CAMPAGNE from '@salesforce/schema/WorkOrder.Campaign__c';
import NOACCESS from '@salesforce/schema/WorkOrder.NoAccessToBuilding__c';
import RENVOIGLOBAL from '@salesforce/schema/WorkOrder.Renvoi_Client_Fonctionnel__c';

export default class LWC01_Workorder extends LightningElement {
    constructor(){
        super();
    }

    saveVisite(event){
        event.preventDefault();

        const fields = event.detail.fields;
        console.log('fields  = ' + JSON.stringify(fields)); 
    }

    handleSave(event){
        event.preventDefault();

        const fields = event.detail.fields;
        console.log('fields  = ' + JSON.stringify(fields)); 
    }

    //Import des champs
    campagne = CAMPAGNE;
    noAccess = NOACCESS;
    renvoiGlobal = RENVOIGLOBAL;
}

HTML:

<lightning-record-edit-form object-api-name="WorkOrder" record-id={recId}>
    <lightning-messages></lightning-messages>           
    <div class="slds-box">
        <lightning-layout vertical-align="center">
            <template if:true={renvoiGlobal}>
                <lightning-layout-item flexibility="auto" padding="around-small" size="6" class="slds-align_left">
                    <lightning-input-field field-name={defautRE}></lightning-input-field>
                </lightning-layout-item>
            </template>
            </lightning-layout-item>
        </lightning-layout>
    </div>
</lightning-record-edit-form>

my condition if:true seems not working so I'd like to retrieve the renvoiGlobal field in a console.log statement but I don't know to proceed.
Thanks!

1 Answer 1

1

The renvoiGlobal variable in your code contains a reference to the field itself, not to the value of the field on your record. It is an object containing the objectApiName and the field api name. You need to set the value of renvoiGlobal to one of the values from the fields variables you have in your handler functions.

1
  • Hello H Alves, Ok i'll try this and let you know. thank you! Mar 11, 2022 at 14:45

You must log in to answer this question.

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