0

I followed the instructions in this blog post to create a Lightning component using force:createrecord -

http://www.infallibletechie.com/2017/11/forcecreaterecord-example-in-salesforce.html

I was able to get this to work perfectly fine. I then created a Lightning app which wrapped the component:

In Dev Console, I then clciked on Preview, and it brought up the button in the component. But when I clicked the button, the call to force:createRecord failed. Why is this happening?

2

I have came across this issue recently and found that this is how force:createRecord event works. The error I see when I debug:

This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://customFieldController/ACTION$getRecId Failing descriptor: {c:customComp}

And in the official Documentation, it was mentioned:

This event is handled by the one.app container. It’s supported in Lightning Experience, Salesforce app, and Lightning communities.

I bet you will not see this error if you have had this component on a Community page. Because, that's how I finally did my testing for force:createRecord event.

|improve this answer|||||
  • It should work well on a community page. Regarding the error: Whenever this force:createRecord event gets fired on a Lightning App, I get this error message on my screen. – Arnold Jr. Feb 21 '18 at 18:38
  • As you said from the documentation, this looks like a problem when using ANY event outside LEX, not just force:createRecord. The "top" Level for the Documentation on using Events says: "If you fire one of these force or lightning events in your Lightning apps or components outside of the Salesforce app or Lightning Experience: You must handle the event by using the <aura:handler> tag in the handling component. Use the <aura:registerEvent> or <aura:dependency> tags to ensure that the event is sent to the client, when needed." So does anyone have an example of how to do this? – hamayoun Feb 22 '18 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.