<aura:attribute name="simpleNewquote" type="Object"/>
component.set("v.simpleNewquote.BillingCountry", "India");
var quoteRecordCreator = component.find("recordEditor");
quoteRecordCreator.saveRecord($A.getCallback(function(saveResult) {
}
try this, you will be able to set the values. So your answer will be Address fields are not restricted to save in LDS.
Actually, you were not setting the values properly.Hope it helps you.
Update:-
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="newquote" type="Object"/>
<aura:attribute name="simpleRecordQuote" type="Quote" />
<aura:attribute name="newquoteError" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<force:recordData aura:id="quoteRecordCreator"
layoutType="FULL"
targetRecord="{!v.newquote}"
targetFields="{!v.simpleRecordQuote}"
targetError="{!v.newquoteError}" />
<aura:if isTrue="{!not(empty(v.newquoteError))}">
<div class="recordError">
<ui:message title="Error" severity="error" closable="true">
{!v.newquoteError}
</ui:message></div>
</aura:if>
<!-- Display the new Quote form -->
<div class="slds-form_stacked">
<lightning:button label="Save quote" onclick="{!c.handleSaveContact}"
variant="brand" class="slds-m-top_medium"/></div>
Controller:-
({
doInit: function(component, event, helper) {
// Prepare a new record from template
component.find("quoteRecordCreator").getNewRecord(
"Quote", // sObject type (objectApiName)
null, // recordTypeId
false, // skip cache?
$A.getCallback(function() {
var rec = component.get("v.newquote");
var error = component.get("v.newquoteError");
if(error || (rec === null)) {
console.log("Error initializing record template: " + error);
return;
}
console.log("Record template initialized: " + rec.sobjectType);
})
);
},
handleSaveContact: function(component, event, helper) {
component.set("v.simpleRecordQuote.OpportunityId", component.get("v.recordId"));
component.set("v.simpleRecordQuote.BillingCountry", "India");
component.set("v.simpleRecordQuote.Name", "Sanket lds");
component.find("quoteRecordCreator").saveRecord(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
// record is saved successfully
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title": "Saved",
"message": "The record was saved."
});
resultsToast.fire();
} else if (saveResult.state === "INCOMPLETE") {
// handle the incomplete state
console.log("User is offline, device doesn't support drafts.");
} else if (saveResult.state === "ERROR") {
// handle the error state
console.log('Problem saving contact, error: ' +
JSON.stringify(saveResult.error));
} else {
console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
}
});
}
})
I have given a component which have a button to create quote,you need to add this component to Oportunity layout and onclick it will fetch the opportunity id and create quote related to it. I am setting BillingCountry successfully.
Hope it helps you.
Update:-
For update you can try like this:-
<aura:component implements="flexipage:availableForRecordHome,force:appHostable,force:hasRecordId">
<aura:attribute name="record" type="Object"/>
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordHandler"
recordId="{!v.recordId}"
layoutType="FULL"
targetRecord="{!v.record}"
targetFields="{!v.simpleRecord}"
targetError="{!v.recordError}"
mode="EDIT"
recordUpdated="{!c.handleRecordUpdated}"
/>
<!-- Display a lightning card with details about the record -->
<div class="Record Details">
<lightning:card iconName="standard:quote" title="{!v.simpleRecord.Name}" >
<div class="slds-p-horizontal--small">
<p class="slds-text-heading--small">
<lightning:formattedText title="Billing State" value="{!v.simpleRecord.BillingState}" /></p>
<p class="slds-text-heading--small">
<lightning:formattedText title="Billing City" value="{!v.simpleRecord.BillingCity}" /></p>
</div>
</lightning:card>
</div>
<!-- Display an editing form -->
<div class="Record Details">
<lightning:card iconName="action:edit" title="Edit Quote">
<div class="slds-p-horizontal--small">
<lightning:input label="quote Name" value="{!v.simpleRecord.Name}"/>
<br/>
<lightning:button label="Save quote" variant="brand" onclick="{!c.handleSaveRecord}" />
</div>
</lightning:card>
</div>
<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
<div class="recordError">
{!v.recordError}</div>
</aura:if>
Controller:-
({
handleSaveRecord: function(component, event, helper) {
component.find("recordHandler").saveRecord($A.getCallback(function(saveResult) {
// NOTE: If you want a specific behavior(an action or UI behavior) when this action is successful
// then handle that in a callback (generic logic when record is changed should be handled in recordUpdated event handler)
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
// handle component related logic in event handler
} else if (saveResult.state === "INCOMPLETE") {
console.log("User is offline, device doesn't support drafts.");
} else if (saveResult.state === "ERROR") {
console.log('Problem saving record, error: ' + JSON.stringify(saveResult.error));
} else {
console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
}
}));
},
/**
* Control the component behavior here when record is changed (via any component)
*/
handleRecordUpdated: function(component, event, helper) {
//here i am setting the field
component.set("v.simpleRecord.BillingCountry", "India");
var eventParams = event.getParams();
if(eventParams.changeType === "CHANGED") {
// get the fields that changed for this record
var changedFields = eventParams.changedFields;
console.log('Fields that are changed: ' + JSON.stringify(changedFields));
// record is changed, so refresh the component (or other component logic)
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title": "Saved",
"message": "The record was updated."
});
resultsToast.fire();
} else if(eventParams.changeType === "LOADED") {
// record is loaded in the cache
} else if(eventParams.changeType === "REMOVED") {
// record is deleted and removed from the cache
} else if(eventParams.changeType === "ERROR") {
// there’s an error while loading, saving or deleting the record
}
}
})
The billingcountry is set similarly in edit mode as creating record.Add this component to quote record home page. here i have added one field on layout, whenever you click the save button, Billing country will get updated to India as i have it default value. Hope it helps you. Mark it as your answer.