You need to sign in to do that
Don't have an account?
Lightning: Issue with force:createRecord and new Date()
Hello
I am having an issue with force:createRecord event to create a new record.
When I invoke this function, the record must be created with a date field called DateMAJCreditsafe__c with today's date by default.
When I click on the button that triggers force:createRecord, I land on Account creation page, and my field is set to today's date, as expected :

But when I save the record, the field is empty :(

I don't understand what I am doing wrong.
This is the call to force:createRecord :
I am having an issue with force:createRecord event to create a new record.
When I invoke this function, the record must be created with a date field called DateMAJCreditsafe__c with today's date by default.
When I click on the button that triggers force:createRecord, I land on Account creation page, and my field is set to today's date, as expected :
But when I save the record, the field is empty :(
I don't understand what I am doing wrong.
This is the call to force:createRecord :
var createRecordEvent = $A.get("e.force:createRecord"); createRecordEvent.setParams({ "entityApiName": "Account", "defaultFieldValues": { 'Name' : name, //set some other fields 'DateMAJCreditsafe__c' : new Date() } }); createRecordEvent.fire();
I have found what was causing the issue.
FLS was set to read-only for that field for the profile I was using.
I unticked Read-only for this profile, then it worked.
Thanks though
All Answers
That should work. I made simple tests without problem with the same createRecordEvent and 'DateMAJCreditsafe__c' : new Date()
Are you sure of DateMAJCreditsafe__c ? (exact value, case sensitive and type (not a formula))
I have found what was causing the issue.
FLS was set to read-only for that field for the profile I was using.
I unticked Read-only for this profile, then it worked.
Thanks though