Activity Forums Salesforce® Discussions How to prepopulate EventWhoids in Salesforce lightning component?

  • How to prepopulate EventWhoids in Salesforce lightning component?

    Posted by Prachi on December 2, 2019 at 4:57 pm

    I am trying to create a lightning component which uses e.force:recordCreate and prepopulates a list of ContactIds in the EventWhoIds field. However, the contact do not get prepopulated in the form.

    console.log(component.get("v.contactIds"));

    var contactRecords = component.get("v.contactIds");
    console.log("contactRecords: " + contactRecords);

    var createEvent = $A.get("e.force:createRecord");
    createEvent.setParams({
    "entityApiName": "Event",
    "defaultFieldValues": {
    'WhatId' : component.get("v.recordId"),
    'EventWhoIds' : contactRecords
    }
    });
    createEvent.fire();

    • This discussion was modified 4 years, 11 months ago by  Prachi.
    • This discussion was modified 4 years, 11 months ago by  Forcetalks.
    • This discussion was modified 4 years, 11 months ago by  Forcetalks.
    Deepak replied 4 years, 11 months ago 2 Members · 1 Reply
  • 1 Reply
  • Deepak

    Member
    December 3, 2019 at 1:08 pm

    recordForm may not work with your use case, and the better approach here would be to use recordEditForm. This is only after discussing this with my team in our internal forum.

    You had a concern that why it doesn't work with recordForm- to which I have mentioned that it will not work with recordForm, and would be better to use recordEditForm.

    Currently, the doc does not mention anything about pre-populating fields. Like any other salesforce doc, it outlines facts, and customizations depend on the person developing the solution. Your use case is a customization.

    I am absolutely not questioning your right to put forward this question. In fact, I understand why do you have this question in the first place. However, what matters here is you having a solution - and recordEditForm would be your best bet here. R&D will not consider changing the doc, as there is nothing mentioned about pre-populating fields there. Pre-populating fields would be a custom use case, and our doc gives general facts of how a recordEditForm works.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos