Context Question for Popups

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I am confused about what line is in context when using a pop up feature with a table. 

I have three models: Events, Attendance, and Contacts. 

The events model is tied to the table with a drawer feature for Attendance and a popup for Contacts. Attendance is connected to Actions via lookup so that field must be filled in.

What should happen is when the Contact pop up is open there is a row action that adds contacts to the Attendance model via the Action framework. Unfortunately, it is only working for the first line in the attendance model and not the row in context (or what I think is context). I put a table from the Event model in the popup to see what line it sees, it shows the correct Event line. However when the record is created in the attendance model it only attaches to the first line in the Event model.

I am using a merge syntax to set the event name: {{$Model.EventModel.data.0.Id}} but it is pulling the first line in the model and not the first line in context.

Any light to shed would be greatly appreciated.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
  • confused

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Tami,

Ca you send some screenshots? I'm having trouble picturing the set-up.

A few items which may be helpful in general:

How is the Contacts popup launched? If it's from a row action on a table, that row will be in context for the popup.

As soon as you create a row with the action framework, that new row becomes the context row.
Photo of Louis Skelton

Louis Skelton

  • 4,826 Points 4k badge 2x thumb
Hi Tami,

Sometimes you have to create a separate Events model (let's call it EventInContactPopup) which is used as the Event to which the Contacts in your popup are added.

So, first, create the above model using the Event object and add a filterable default off condition on the ID field. It would also have a 1 row limit and would not load data on page-load. Then, clicking on the popup button on your Events table triggers the following actions:
  1. Take ID of current Event row in table and Activate and Set Value of condition on the EventInContactPopup model
  2. Requery the new event model
You can now assign additional Contacts to your EventInContactPopup Event model.

Once you've saved those changes you would then need to also requery the Attendance model.

Apologies in advance if this is not the right solution!
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Louis,

This looks fantastic. I am going to give it a go tonight and I will report back. Thank you for taking the time to run through this for me!
Photo of Louis Skelton

Louis Skelton

  • 4,826 Points 4k badge 2x thumb
No worries Tami! Someone might step in with a smarter solution but this should get you started. Your issue stems from the {{$Model.EventModel.data.0.Id}} merge field you were using. As I understand it the '0' in this represents the first row of the model. So you will always be getting the first Event in the model when using the above merge field. As such, you need to make your own model which limits the number of events to only the one you are working with. That way, {{$Model.EventInContactPopup.data.0.Id}} will always produce the correct event.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Therein lies my confusion.  I understood the merge syntax was calling the first row of the model but I thought it would take into account if the condition I set up. I think your idea is going to work great. I was thinking I needed another model but I couldn't wrap my head around what model it should be. It is great to bounce idea's off of someone. Thanks alot. I will report back when I set up and test.
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
Louis,

The extra model is exactly what I needed. Thank you so much for your help.

Have a great day!
Photo of Louis Skelton

Louis Skelton

  • 4,826 Points 4k badge 2x thumb
I'm so glad it worked!

Have a good one!
Photo of Tami Lust

Tami Lust

  • 5,280 Points 5k badge 2x thumb
I should have put pictures up to begin with sorry about that. Please let me know if it is clear now.

Here is how it looks to a user:

  • So what should happen is when the plus icon is clicked on the Events Model the Popup with the Contact model is shown (see next screen shot)



  • Here is what the popup looks like (the Attendance and Event model are shown here only for testing)
  • Clicking the wands on the contact model add the contact to the attendance model the action name (Event Model) must be filled in and should be that of the line shown in the Event Model. 
  • What is happening is it filling in the Action name from the first row of the Event Model and not the row shown here.