I am using the Lightning Data service in my Lightning Component to update a case record, before I do update the record I need to check on the field value and update accordingly. Below is my component
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="loaded" type="Boolean" default="false" />
<lightning:spinner variant="brand" alternativeText="Loading..." class="{!(v.loaded? 'slds-show': 'slds-hide')}" />
<lightning:recordEditForm aura:id="form"
objectApiName="Case"
recordId="{!v.recordId}"
onsubmit="{!c.handleSubmit}"
onerror="{!c.handleError}"
onsuccess="{!c.handleSuccess}">
<lightning:inputField aura:id="statusInput" fieldName="Status" class="slds-hide" />
<lightning:button variant="brand" type="submit" label="Transfer" />
</lightning:recordEditForm>
</aura:component>
and the controller is like
{
handleSubmit: function(component, event, helper) {
component.set('v.loaded',true);
event.preventDefault();
var fields = event.getParam('fields');
var country = fields.Account_Country__c;
if( country == 'XYZ')
{
fields.OwnerId = 'XXXXXXXXXX';
}
else
{
fields.OwnerId = 'YYYYYYYYYYY';
}
console.log(JSON.stringify(fields));
component.find('form').submit(fields);
$A.get("e.force:refreshView").fire();
},
Here the country field is always undefined in the controller I tried even changing the to like below
var country = component.get("v.recordId").Account_Country__c;
Even this is not returning the field value associated with the case record.How can I reterieve the field value so I can use them in the controller.