function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vanitha ManiVanitha Mani 

How to update value in detail page

Hi,

I have finish button..which when clicked the field status in case object shd get updated to Resolved..I tried the following code but dint work..Can anyone help me with this.

<lightning:recordEditForm 
        recordId="{!v.recordId}"
        objectApiName="Case">
        <lightning:messages />
            <div class="slds-grid">
                <div class="slds-col slds-size_1-of-2 slds-hide">
                    <lightning:inputField fieldName ="Status__c" aura:id ="Consent" value ="" />
                </div>
    </div>
    
                    <lightning:button label="Finish" variant="brand" onclick="{!c.update}"/>
                    </lightning:recordEditForm>

Controller
component.find("Consent").set("v.value", "Resolved");

when i tried alert(component.find("Consent"));

I am getting error like
SecureComponentRef: InteropComponent: markup://lightning:inputField{ key: {"namespace":"c"} }
Best Answer chosen by Vanitha Mani
Maharajan CMaharajan C
Hi Vanitha,

Try the below code:

cmp:
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
    
    <lightning:recordEditForm 
                              recordId="{!v.recordId}"
                              objectApiName="Case"
                              aura:id="myRecordForm"
                              onsubmit="{!c.update}">
        <lightning:messages />
        <div class="slds-grid">
            <div class="slds-col slds-size_1-of-2 slds-hide">
                <lightning:inputField fieldName ="Status__c" aura:id ="Consent" value ="" />
            </div>
        </div>
        
        <lightning:button variant="brand" label="Finish" type="submit" />
    </lightning:recordEditForm>
    
</aura:component>

JS:
 
({
    update : function(component, event, helper) {
        console.log('update:');
        var fields = event.getParam("fields");
        fields["Status__c"] = 'Resolved';
        component.find('myRecordForm').submit(fields);
    }
})

Thanks,
Maharajan.C