You need to sign in to do that
Don't have an account?
Save attribute to record
I am trying to set a Lightning Component attribute to a record field. The field is "PersonMailingCity" on the Person Account object, and my code I call the attribute "City". I have created an alert in the JS which displays the City properly, but how can I get that to save to the record? I have this as an attribute as it it calling a separate database to return the City value. I can get my other fields to populate into the record however the "City" will not work. Code below:
Cmp:
JS Controller:
Cmp:
<aura:attribute name="City" type="String" /> <force:recordData aura:id="recordHandler" recordId="{!v.acctId}" layoutType="FULL" fields="Id, FirstName, LastName, PersonEmail, PersonMailingCity, etc." targetFields ="{!v.editAccountFields}" targetError="{!v.editAccountError}" mode="EDIT" /> <ui:inputText aura:id="city" value="{!v.City}" label="City" updateOn="keyup"/> <lightning:button label="Next" onclick="{!c.next}" variant="brand" />
JS Controller:
next : function(component, event, helper) { component.set("v.editAccountFields.Id", component.get("v.acctId")); component.set("v.editAccountFields.PersonMailingCity",component.get("v.City")); alert('City is ' + component.get("v.editAccountFields.PersonMailingCity")); var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "", "message": " - Address has been updated - ", "type": "success" }); toastEvent.fire(); },