Save and New on a Popup

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Hi,

I'm trying to accomplish the following:

I have a button on lead, that opens a popup that allow us to create a New related Record (loan)

I'm trying to add a button on that popup page(which is a  page include) to Save & New (basically allow to create another record within that popup)
From what i tried:

URL Redirect cannot work as it does not redirect on the popup frame, but on the parent
So tried the following sequence of action:

-Save model (for 1st record i created)
-Close topmost popup
-Show popup with the same page include used in step 1, and pass the model's ID for first row (which should always be there, as we just created one on step 1...)

But no matter what I try, the Id would not pass, therefore the second new record i created is not related to any lead

Console shows the same

I cannot see why...

Any ideas?

Maybe there's even a simpler way to accomplish allowing to create new records, one after the other, within the same or a new popup?

Any help would be appreciated

Thx
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 2 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I have to do the same thing this week. I was planning on running a snippet to click the button again after closing topmost popup.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I've had similar issues. Can you do it without the page include? Instead build models and components in the parent page? You may have better luck.
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Yes and no Raymond,

The problem is,if I understand correctly, I would need to recreate it Infinitely ...as if use parent page & model, the popup will have a button to save and new, and that popup will need again another popup for save and new and so on....

I'm sure the scenario i explained in OP could work, just need to figure out how to pass the ID

Will keep on trying.

Thx
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Ok good news I got it to work somewhat,

Except 1 issue I still cannot figure out it works as intended.

here's action framework for Save & New Button On page include for new record

1)Save model (to save 1st record i created)
2)Close topmost popup
-Show popup with the same page include used in step 1, and pass the Lead ID from 1st record(or any) i created for same lead

What i was trying before was passing the in query string via this syntax:

id={{$Model.MYMODEL.data.0.Lead__c}}

Also this would not work 

id={{Lead__c}}

When I tried this , it seems to work now

id={{{Lead__c}}}

The only issue left, is for some reason the "After Close Actions" (requery model) is not working with that method...

If i requery model through a filter or refrsh page.. they show up

Hope it helps 

And hope someone has an idea for the after close query not working.

Thx
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Glad you got this working. I had a page include in a tab that I tried for hours to do this and I couldn't get it to work. My problem though, as I think about it, was conditionally rendered fields. I could get it to create a new row after save, but some fields wouldn't appear even though their conditions should have caused them to render.
Not sure about after close actions, but I believe you can requery a model in a parent page from a page include if you hack the XML. Then you could build the requery into the button actions in your page include. To do this, you create a dummy model in your page include page and add an action to requery that model in your button actions. The you open the XML and manually change the name of the dummy model to the model in your parent page. Make sure the parent page models never match the names of your page include models, of course.