Lightning event: e.force:createRecord
Lightning event: e.force:createRecord

Lightning event: e.force:createRecord

Recently we had a necessity to create a custom dynamic lightning component for related list. In order to build the related list with additional features dynamically according to the indicated objects “parent” and “child”.

One part from additional functions which was necessary to implement was actually a clone on the level “row” and a button “+ Add Line”.

For these actions we decided to use lightning standard event $A.get("e.force:createRecord").

For the clone we transmitted default values to the attribute “defaultFieldValues”.

However, while testing we have spotted an issue with the object “OpportunityLineItem”.

The modal window for objects creation could be opened but in attempt to change the lookup for a product we had the following:

It appeared that one more parameter in the event $A.get("e.force:createRecord") - inContextOfRecordId.

inContextOfRecordId parameter is a required field for OpportunityLineItem, QuoteLineItem, OrderItem, ContractLineItem, WorkOrderLineItem entities.

Further we have to use inContextOfRecordId to pass the recordId when we want to create OpportunityLineItem by using force:createRecord.

Sample example for OpportunityLineItem creation:

createRecord : function (component, event, helper) { 

    var createRecordEvent = $A.get("e.force:createRecord"); 

    createRecordEvent.setParams({ 

        "entityApiName": "OpportunityLineItem" , 

        "inContextOfRecordId": component.get("v.recordId"), 
 
    }); 

    createRecordEvent.fire(); 

}

In case if someone else faces this kind of issues, at least here is the solution. We are not greedy and we are trying to share our findings and some solutions that we came to. Hope this article was very useful. If you have any additional questions, feel free to leave your comments to the article.  





要查看或添加评论,请登录

Anastasia Sapihora ??的更多文章

  • Trip to FrechTouchDreaming`23

    Trip to FrechTouchDreaming`23

    The trip to Paris was supposed to take less than 1 day. But actually it ended up from 9:00 am November 26, 2023 - 12:00…

    3 条评论
  • LULC Version 3.11 Release notes

    LULC Version 3.11 Release notes

    Again, we are ready to introduce you a new version of the Lookup Field component. Our road map is always based on your…

  • LULC Version 3.x Release notes

    LULC Version 3.x Release notes

    Link to AppExchange Once again, we would like to introduce you a new version of the Lookup Field component. Despite the…

  • Lookup Universal Lookup Component - Flow supporting

    Lookup Universal Lookup Component - Flow supporting

    Probably you already read articles in our blog about the Universal Lookup Component. We pay attention to every feedback…

  • Lightning Universal Lookup Component Version 2.0

    Lightning Universal Lookup Component Version 2.0

    As always, our company does not wish to stop even for a second and trying to improve products and services constantly…

  • Lightning Universal Lookup Component

    Lightning Universal Lookup Component

    Boost the development of your custom components with a new powerful lookup component. It looks like a standard one…

社区洞察

其他会员也浏览了