1

I have below code to create case record using e.force.createRecord. But it is not firing the assignment rule of a case. Can anyone look into this and what should i update in order to fire assignment rules?

var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "Case",
"recordTypeId" : recordTypeId
});
 createRecordEvent.fire();

3 Answers 3

1

Just to be clear, force:createRecord does not create a record.

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities. This event presents a standard page to create a record. That is, it doesn’t respect overrides on the object’s create action.

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_createRecord.htm

It presents a standard record create pop-up, pre-populated by the indicated values, and it's up to the user to fill in the form and click Save. Then a record is created. If you're not getting the pop-up in your Lightning Community that's one issue. If you're getting the pop-up and clicking Save and the record gets created but no assignment rules are triggered that's another issue. Which is it?

If your intended behaviour was just to create the record without user intervention, look into Lightning Data Service.

4
  • Charles - I am getting the pop-up to create a case and it is getting saved. But Assignment Rules are not firing. Dec 26, 2017 at 14:52
  • OK so it sounds like the real problem is, force:createRecord does not give you the equivalent of pre-setting the checkbox selecting whether to execute assignment rules on insert. Does the checkbox appear at all? Have you placed it on the layout? Can you get assignment rules to fire when an internal (non-community) user clicks the New button in Lightning Experience?
    – Charles T
    Dec 26, 2017 at 16:16
  • Problem is with only community users, for non community users checkbox appears. Dec 27, 2017 at 12:35
  • Interesting. I think it makes sense that community users not see such a box because it's meaningless to them - if I'm submitting a support case I have no idea WTF an assignment rule is and why it matters to me. Perhaps you would be best to set up a trigger in the back end which kicks off the assignment rules after a community user creates a case. Or use something like this free managed package which can help you trigger assignment rules from within Process Builder: appexchange.salesforce.com/…
    – Charles T
    Dec 27, 2017 at 17:02
0

Assignment rules are usually "triggered" when certain conditions are met, for example, when certain fields match a certain value.

if you dont set the proper parameters when creating your case using "e.force:createRecord" it is normal that your assignment rules dont work.

6
  • Rules are correct and from classic it works perfectly. But it is not working in Lightning e.force.createRecord Dec 22, 2017 at 17:46
  • what are your assignment rules? please update your post accordingly.
    – glls
    Dec 22, 2017 at 17:49
  • As mention rule is correct and it works perfectly in Classic. But samething when i try in lightning it is not working. Dec 22, 2017 at 18:07
  • maybe i dont understand something, which is why i am asking for more details. not if it is working in classic or not. what are your field conditions that trigger your assignment rule(s)?
    – glls
    Dec 22, 2017 at 18:14
  • It works in classic, Criteria is if case status = 'Open' route it to a ABC queue. Dec 22, 2017 at 18:26
0

Assignment Rules execute when a record is saved to the database. force:createRecord doesn't actually save a record, so there's nothing to execute. Wether or not it will work depends on the Case Page Layout and if the user selects the Assign Using Active Assignment Rule option.

In other words, it's not a code issue, but a configuration issue. Go to your page layouts, and select the Show Assignment Checkbox and Select Assignment Checkbox Automatically options.

1
  • Hi, Finally i found why assignment rules are not firing. I am executing this code in the community Napili template and it seems to be a bug from salesforce. Dec 23, 2017 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .