1

Is this a duplicate?

This is not an duplicate of Lightning force:createRecord capture redirect after save

because I'm additionally looking for a solution primarily for VF an not only LC. I can't use "panelOnDestroyCallback" directly, even if it would work. Trying this even worse hack instead also failed and the console.log will be never reached:

SfdcApp.projectOneNavigator.fireContainerEvent(
    "force:createRecord"
  , { entityApiName: 'Account'
        , "panelOnDestroyCallback": function(event) { 
               console.log('TEST') 
        }  
  } 
);

So the question is similar, but not the same.

ORIGINAL QUESTION

I'm using sforce.one.createRecord() in VF and $A.get("e.force:createRecord") in LCs to get a popup for creating new records it works fine in both worlds even with the feature to prepopulate default values, e.g. like this

sforce.one.createRecord( 
      objectName 
    , null
    , { parentLookupFieldName : parentRecordId } 
);

Basic use case is to overcome the limits of the Standard Related List components, such as limit to 4 columns, card-mode in narrow columns instead of table-mode and much more limits we have in LEX right now.

Rest assured, that objectName, parentLookupFieldName and parentRecordId are fine. In LEX it looks:

This sits on a Record Flexipage. Instead of the VF version, it could also be a LC firing $A.get("e.force:createRecord") with practically the same outcome.

enter image description here

Now after clicking on SAVE, the platform reroutes me to the new record.

This rerouting might be a feature in some scenarios, but for sure this is NOT OK for my process. Instead I need to stick at the record, from where I have hammered the "New" button. I must not leave that record on the UI, but I need to reload (or refresh) the record in order to make the new record appear in the related list.

Now I doubt that this is supported in a "straight forward" manner, but I would be happy to hack something, e.g. navigate back to the original record or whatever.

Has anybody an idea on how to do that?

  • 1
    Possible duplicate of Lightning force:createRecord capture redirect after save – Praveen Aug 15 '18 at 16:19
  • I don't have time to test the theory but you might be able to register a handler in your component for aura:applicationEvent or force:recordSaveSuccess or force:afterRecordSave and then stop the event's normal behavior of redirecting by leveraging event.preventDefault() and then your handler can fire a force:refreshView event to refresh the page. – Mark Pond Aug 15 '18 at 18:29

Your Answer

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

Browse other questions tagged or ask your own question.