About this question
Lightning force:record data shows following error: Uncaught Type Error: Cannot read property 'ValuePick__c' of null If I write like this error will disappear Why getting this error and how to resolve it?
Lightning force:record data shows following error: Uncaught Type Error: Cannot read property 'ValuePick__c' of null If I write like this error will disappear Why getting this error and how to resolve it?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Salesforce Expert
Answered on Jul 19, 2021
force:recordData is missing a recordId, so there's nothing being pulled into v.UserSkillFields. Then when input is attempting to set input value equal to v.UserSkillFields.valueFields, it's drawing a null because nothing has been loaded into that attribute. Try including a recordId attribute in your force:recordData tag, and set it with either force:has recordedld or an init handler that sets the recordId attr with an Id string. If you're doing the latter you may have to reload recordData with .reloadRecord() to load associated field values. Then you should be able to set value of inputField.
** revision **
On further inspection, it seems like you're trying to default the GSS_User_Skill__c .ValuePick__c field to a parent record's field value. To resolve this error” cannot read property of null”,you can try the following set the parent record (UserSkillFields) id (in init) reload UserSkillFields (also in init) grab the reloaded UserSkillFields via component.get("v.UserSkillFields") explicitly pre-populate lightning:inputField value attribute with reloaded object's corresponding field value (via the force:recordEditForm onLoad() property)
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step Salesforce guides from industry experts
Common Salesforce interview questions, answered
Guides, tips and career advice on Salesforce from JanBask experts.
Salesforce How to Get Into Salesforce With No Experience
Wondering if you can get a Salesforce job with no experience? Learn how to pick a career path, build real skills, and land your…
Salesforce How to Become a Salesforce Developer Without Experience
No coding background? Learn how to become a Salesforce Developer step by step - skills to build, projects to create, and how to…
Salesforce How to Become a Salesforce Admin With No Experience
No Salesforce Admin experience? Learn how to build real skills, create projects, and land an entry-level Salesforce Admin job…
Salesforce How Long Does It Take to Become a Salesforce Developer?
Wondering how long to learn Salesforce Developer? Most beginners need 6–12 months. See the study time, stage-by-stage roadmap and…