Lightning: Fields on Record loaded via force:recordData appear to be read-only / unwriteable
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
Scenario: I am loading an existing record using force:recordData
, but since this component isn't on a record page, it cannot/does not implement force:hasRecordId
. Instead, I created an attribute called !v.contactId
and I set that as the recordId parameter on the force:recordData
component. Before init, the contactId attribute is null, but I set it to a valid Contact Id during init, and then afterwards I run the .reloadRecord()
method on the recordData
component which reloads the record.
Issue: The record is loaded from the database, the
simpleContactRecord
attribute returns all of the expected fields, I can set a
lightning:input
field value to show the Phone number from the contact
using!v.simpleContactRecord.Phone
, but when I try to modify the
value in the input field, it doesn't let me. The data shows correctly
on the screen and I can place my cursor into the input field, but if I
try to type anything or delete any existing data it doesn't do
anything. Likewise, if I try to programmatically set the variables
during a save call usingcomponent.set("v.simpleContactRecord.Phone,
and then saving the record, it doesn't update the
"5555555555");
value.
Based on some other posts and documentation I found online, it seems
like I am approaching the loading of the record correctly - since
there is no record Id available to the page, I need to set it manually
(which I do), and then force a reload of the record (which I do). I
don't understand why I can't edit or update any of the data in this
record, especially since I'm explicitly setting theMode="EDIT"
parameter on therecordData
component. What am I doing wrong?
The full code from my test component is below:
Component:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" Controller="CreateTicketController">
<aura:attribute name="contactId" type="String" />
<aura:attribute name="userId" type="String" />
<!-- START: Contact Object Records -->
<aura:attribute name="contactRecord" type="Object" />
<aura:attribute name="simpleContactRecord" type="Object" />
<aura:attribute name="contactRecordError" type="String" />
<!-- END: Contact Object Records -->
<aura:handler name="init" value="!this" action="!c.init" />
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT"
layoutType="FULL"
targetRecord="!v.contactRecord"
targetFields="!v.simpleContactRecord"
targetError="!v.contactRecordError"
recordId="!v.contactId"
recordUpdated="!c.handleRecordUpdated" />
<form>
<lightning:input type="tel" aura:id="phone" label="Phone" name="Phone" value="!v.simpleContactRecord.Phone" />
</form>
<div class="slds-form-element">
<span><br /><lightning:button onclick="!c.save" label="Submit" class="slds-button slds-button_brand slds-text-heading_small" /></span>
</div>
</aura:component>
Client-Side Controller:
(
init: function (component, event, helper)
console.log('Init actionz');
var action = component.get("c.getRelatedAccounts");
var userId = $A.get('$SObjectType.CurrentUser.Id');
var contactId;
var relationships;
console.log('Test Init Actions');
component.set("v.userId",userId);
action.setParams(
"userId": userId
);
action.setCallback(this, function(response)
var state = response.getState();
console.log('Response State: ' + state);
console.log('is Valid: ' + component.isValid());
if(component.isValid() && state == "SUCCESS")
relationships = JSON.parse(response.getReturnValue());
console.log('Relationship Length: ' + relationships.length);
console.log('Relationship 0 Account Id: ' + relationships[0].Contact.AccountId);
contactId = relationships[0].ContactId;
console.log('Contact Id: ' + contactId);
component.set("v.contactId", contactId);
component.find("contactRecordEditor").reloadRecord(
true,
$A.getCallback(function() )
);
);
// Invoke the service
$A.enqueueAction(action);
)
lightning-components edit force-recorddata
add a comment |Â
up vote
1
down vote
favorite
Scenario: I am loading an existing record using force:recordData
, but since this component isn't on a record page, it cannot/does not implement force:hasRecordId
. Instead, I created an attribute called !v.contactId
and I set that as the recordId parameter on the force:recordData
component. Before init, the contactId attribute is null, but I set it to a valid Contact Id during init, and then afterwards I run the .reloadRecord()
method on the recordData
component which reloads the record.
Issue: The record is loaded from the database, the
simpleContactRecord
attribute returns all of the expected fields, I can set a
lightning:input
field value to show the Phone number from the contact
using!v.simpleContactRecord.Phone
, but when I try to modify the
value in the input field, it doesn't let me. The data shows correctly
on the screen and I can place my cursor into the input field, but if I
try to type anything or delete any existing data it doesn't do
anything. Likewise, if I try to programmatically set the variables
during a save call usingcomponent.set("v.simpleContactRecord.Phone,
and then saving the record, it doesn't update the
"5555555555");
value.
Based on some other posts and documentation I found online, it seems
like I am approaching the loading of the record correctly - since
there is no record Id available to the page, I need to set it manually
(which I do), and then force a reload of the record (which I do). I
don't understand why I can't edit or update any of the data in this
record, especially since I'm explicitly setting theMode="EDIT"
parameter on therecordData
component. What am I doing wrong?
The full code from my test component is below:
Component:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" Controller="CreateTicketController">
<aura:attribute name="contactId" type="String" />
<aura:attribute name="userId" type="String" />
<!-- START: Contact Object Records -->
<aura:attribute name="contactRecord" type="Object" />
<aura:attribute name="simpleContactRecord" type="Object" />
<aura:attribute name="contactRecordError" type="String" />
<!-- END: Contact Object Records -->
<aura:handler name="init" value="!this" action="!c.init" />
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT"
layoutType="FULL"
targetRecord="!v.contactRecord"
targetFields="!v.simpleContactRecord"
targetError="!v.contactRecordError"
recordId="!v.contactId"
recordUpdated="!c.handleRecordUpdated" />
<form>
<lightning:input type="tel" aura:id="phone" label="Phone" name="Phone" value="!v.simpleContactRecord.Phone" />
</form>
<div class="slds-form-element">
<span><br /><lightning:button onclick="!c.save" label="Submit" class="slds-button slds-button_brand slds-text-heading_small" /></span>
</div>
</aura:component>
Client-Side Controller:
(
init: function (component, event, helper)
console.log('Init actionz');
var action = component.get("c.getRelatedAccounts");
var userId = $A.get('$SObjectType.CurrentUser.Id');
var contactId;
var relationships;
console.log('Test Init Actions');
component.set("v.userId",userId);
action.setParams(
"userId": userId
);
action.setCallback(this, function(response)
var state = response.getState();
console.log('Response State: ' + state);
console.log('is Valid: ' + component.isValid());
if(component.isValid() && state == "SUCCESS")
relationships = JSON.parse(response.getReturnValue());
console.log('Relationship Length: ' + relationships.length);
console.log('Relationship 0 Account Id: ' + relationships[0].Contact.AccountId);
contactId = relationships[0].ContactId;
console.log('Contact Id: ' + contactId);
component.set("v.contactId", contactId);
component.find("contactRecordEditor").reloadRecord(
true,
$A.getCallback(function() )
);
);
// Invoke the service
$A.enqueueAction(action);
)
lightning-components edit force-recorddata
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Scenario: I am loading an existing record using force:recordData
, but since this component isn't on a record page, it cannot/does not implement force:hasRecordId
. Instead, I created an attribute called !v.contactId
and I set that as the recordId parameter on the force:recordData
component. Before init, the contactId attribute is null, but I set it to a valid Contact Id during init, and then afterwards I run the .reloadRecord()
method on the recordData
component which reloads the record.
Issue: The record is loaded from the database, the
simpleContactRecord
attribute returns all of the expected fields, I can set a
lightning:input
field value to show the Phone number from the contact
using!v.simpleContactRecord.Phone
, but when I try to modify the
value in the input field, it doesn't let me. The data shows correctly
on the screen and I can place my cursor into the input field, but if I
try to type anything or delete any existing data it doesn't do
anything. Likewise, if I try to programmatically set the variables
during a save call usingcomponent.set("v.simpleContactRecord.Phone,
and then saving the record, it doesn't update the
"5555555555");
value.
Based on some other posts and documentation I found online, it seems
like I am approaching the loading of the record correctly - since
there is no record Id available to the page, I need to set it manually
(which I do), and then force a reload of the record (which I do). I
don't understand why I can't edit or update any of the data in this
record, especially since I'm explicitly setting theMode="EDIT"
parameter on therecordData
component. What am I doing wrong?
The full code from my test component is below:
Component:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" Controller="CreateTicketController">
<aura:attribute name="contactId" type="String" />
<aura:attribute name="userId" type="String" />
<!-- START: Contact Object Records -->
<aura:attribute name="contactRecord" type="Object" />
<aura:attribute name="simpleContactRecord" type="Object" />
<aura:attribute name="contactRecordError" type="String" />
<!-- END: Contact Object Records -->
<aura:handler name="init" value="!this" action="!c.init" />
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT"
layoutType="FULL"
targetRecord="!v.contactRecord"
targetFields="!v.simpleContactRecord"
targetError="!v.contactRecordError"
recordId="!v.contactId"
recordUpdated="!c.handleRecordUpdated" />
<form>
<lightning:input type="tel" aura:id="phone" label="Phone" name="Phone" value="!v.simpleContactRecord.Phone" />
</form>
<div class="slds-form-element">
<span><br /><lightning:button onclick="!c.save" label="Submit" class="slds-button slds-button_brand slds-text-heading_small" /></span>
</div>
</aura:component>
Client-Side Controller:
(
init: function (component, event, helper)
console.log('Init actionz');
var action = component.get("c.getRelatedAccounts");
var userId = $A.get('$SObjectType.CurrentUser.Id');
var contactId;
var relationships;
console.log('Test Init Actions');
component.set("v.userId",userId);
action.setParams(
"userId": userId
);
action.setCallback(this, function(response)
var state = response.getState();
console.log('Response State: ' + state);
console.log('is Valid: ' + component.isValid());
if(component.isValid() && state == "SUCCESS")
relationships = JSON.parse(response.getReturnValue());
console.log('Relationship Length: ' + relationships.length);
console.log('Relationship 0 Account Id: ' + relationships[0].Contact.AccountId);
contactId = relationships[0].ContactId;
console.log('Contact Id: ' + contactId);
component.set("v.contactId", contactId);
component.find("contactRecordEditor").reloadRecord(
true,
$A.getCallback(function() )
);
);
// Invoke the service
$A.enqueueAction(action);
)
lightning-components edit force-recorddata
Scenario: I am loading an existing record using force:recordData
, but since this component isn't on a record page, it cannot/does not implement force:hasRecordId
. Instead, I created an attribute called !v.contactId
and I set that as the recordId parameter on the force:recordData
component. Before init, the contactId attribute is null, but I set it to a valid Contact Id during init, and then afterwards I run the .reloadRecord()
method on the recordData
component which reloads the record.
Issue: The record is loaded from the database, the
simpleContactRecord
attribute returns all of the expected fields, I can set a
lightning:input
field value to show the Phone number from the contact
using!v.simpleContactRecord.Phone
, but when I try to modify the
value in the input field, it doesn't let me. The data shows correctly
on the screen and I can place my cursor into the input field, but if I
try to type anything or delete any existing data it doesn't do
anything. Likewise, if I try to programmatically set the variables
during a save call usingcomponent.set("v.simpleContactRecord.Phone,
and then saving the record, it doesn't update the
"5555555555");
value.
Based on some other posts and documentation I found online, it seems
like I am approaching the loading of the record correctly - since
there is no record Id available to the page, I need to set it manually
(which I do), and then force a reload of the record (which I do). I
don't understand why I can't edit or update any of the data in this
record, especially since I'm explicitly setting theMode="EDIT"
parameter on therecordData
component. What am I doing wrong?
The full code from my test component is below:
Component:
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" Controller="CreateTicketController">
<aura:attribute name="contactId" type="String" />
<aura:attribute name="userId" type="String" />
<!-- START: Contact Object Records -->
<aura:attribute name="contactRecord" type="Object" />
<aura:attribute name="simpleContactRecord" type="Object" />
<aura:attribute name="contactRecordError" type="String" />
<!-- END: Contact Object Records -->
<aura:handler name="init" value="!this" action="!c.init" />
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT"
layoutType="FULL"
targetRecord="!v.contactRecord"
targetFields="!v.simpleContactRecord"
targetError="!v.contactRecordError"
recordId="!v.contactId"
recordUpdated="!c.handleRecordUpdated" />
<form>
<lightning:input type="tel" aura:id="phone" label="Phone" name="Phone" value="!v.simpleContactRecord.Phone" />
</form>
<div class="slds-form-element">
<span><br /><lightning:button onclick="!c.save" label="Submit" class="slds-button slds-button_brand slds-text-heading_small" /></span>
</div>
</aura:component>
Client-Side Controller:
(
init: function (component, event, helper)
console.log('Init actionz');
var action = component.get("c.getRelatedAccounts");
var userId = $A.get('$SObjectType.CurrentUser.Id');
var contactId;
var relationships;
console.log('Test Init Actions');
component.set("v.userId",userId);
action.setParams(
"userId": userId
);
action.setCallback(this, function(response)
var state = response.getState();
console.log('Response State: ' + state);
console.log('is Valid: ' + component.isValid());
if(component.isValid() && state == "SUCCESS")
relationships = JSON.parse(response.getReturnValue());
console.log('Relationship Length: ' + relationships.length);
console.log('Relationship 0 Account Id: ' + relationships[0].Contact.AccountId);
contactId = relationships[0].ContactId;
console.log('Contact Id: ' + contactId);
component.set("v.contactId", contactId);
component.find("contactRecordEditor").reloadRecord(
true,
$A.getCallback(function() )
);
);
// Invoke the service
$A.enqueueAction(action);
)
lightning-components edit force-recorddata
lightning-components edit force-recorddata
asked 3 hours ago
Morgan Marchese
1,388426
1,388426
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
I don't understand why I can't edit or update any of the data in this record, especially since I'm explicitly setting the Mode="EDIT" parameter
Your whole issue is exactly on that line where you are setting the mode. Hint - case sensitivity.
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT" // this is the culprit here!
...
...
/>
And the root cause is the UPPERCASE M in mode.
Change it to mode=EDIT
, and you will see it working.
<force:recordData aura:id="contactRecordEditor"
mode="EDIT"
...
...
/>
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
I don't understand why I can't edit or update any of the data in this record, especially since I'm explicitly setting the Mode="EDIT" parameter
Your whole issue is exactly on that line where you are setting the mode. Hint - case sensitivity.
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT" // this is the culprit here!
...
...
/>
And the root cause is the UPPERCASE M in mode.
Change it to mode=EDIT
, and you will see it working.
<force:recordData aura:id="contactRecordEditor"
mode="EDIT"
...
...
/>
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
I don't understand why I can't edit or update any of the data in this record, especially since I'm explicitly setting the Mode="EDIT" parameter
Your whole issue is exactly on that line where you are setting the mode. Hint - case sensitivity.
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT" // this is the culprit here!
...
...
/>
And the root cause is the UPPERCASE M in mode.
Change it to mode=EDIT
, and you will see it working.
<force:recordData aura:id="contactRecordEditor"
mode="EDIT"
...
...
/>
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
I don't understand why I can't edit or update any of the data in this record, especially since I'm explicitly setting the Mode="EDIT" parameter
Your whole issue is exactly on that line where you are setting the mode. Hint - case sensitivity.
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT" // this is the culprit here!
...
...
/>
And the root cause is the UPPERCASE M in mode.
Change it to mode=EDIT
, and you will see it working.
<force:recordData aura:id="contactRecordEditor"
mode="EDIT"
...
...
/>
I don't understand why I can't edit or update any of the data in this record, especially since I'm explicitly setting the Mode="EDIT" parameter
Your whole issue is exactly on that line where you are setting the mode. Hint - case sensitivity.
<force:recordData aura:id="contactRecordEditor"
Mode="EDIT" // this is the culprit here!
...
...
/>
And the root cause is the UPPERCASE M in mode.
Change it to mode=EDIT
, and you will see it working.
<force:recordData aura:id="contactRecordEditor"
mode="EDIT"
...
...
/>
answered 3 hours ago
Jayant Das
8,3702421
8,3702421
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
add a comment |Â
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
1
1
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
Damn. I always miss the easy stuff. I guess I have to burn "Lightning components are case sensitive" into my brain. I'm still learning all of the new lightning component stuff so pardon my dust while I clear out my brain of old habits. Thanks again Jayant
â Morgan Marchese
1 hour ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f237201%2flightning-fields-on-record-loaded-via-forcerecorddata-appear-to-be-read-only%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password