row action redirect - how can I get the index of the selected row?

  • 1
  • Question
  • Updated 5 years ago
  • Answered
I have a table of Incomes. I want to have a row action that redirects to a Make Payment page. I want to pass a few of the selected row's fields as URL parameters to the new page. I do this in a number of places where I'm dealing with a model that HAS only one row. In those cases, I use this syntax:

?id={{$Model.Income.data.0.Donor__c}}

This works in cases where the model has only a single row, because '0' is the index of the first row in the model.

I know that skuid.utils.merge has a notion of "index" for a row, but I don't know if there is any way to use that in this context. Here is my full redirect URL:

apex/c__AddPayment?id={{$Model.Income.data.0.Donor__c}}&donor={{$Model.Income.data.0.Donor__c}}&income={{$Model.Income.data.0.Id}}&finishURL=%2Fapex%2FIncomePaymentTab&cancelURL=%2Fapex%2FIncomePaymentTab

What I want to know is how (if) I can replace '0' with something that will give me the index of the row for which the row action was clicked.
Photo of Ken Neff

Ken Neff

  • 408 Points 250 badge 2x thumb

Posted 5 years ago

  • 1
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
Ken,

You absolutely can accomplish this. If the field you are trying to merge is in the model that is bound to your table (which it sounds like this is the case), you can reference the field directly, without the "$Model.[sObject].data.[index]" part. Try this redirect URL for you row action:

apex/c__AddPayment?id={{Donor__c}}&donor={{Donor__c}}&income={{Id}}&finishURL=%2Fapex%2FIncomePaymentTab&cancelURL=%2Fapex%2FIncomePaymentTab
Photo of Ken Neff

Ken Neff

  • 408 Points 250 badge 2x thumb
Thanks! This was exactly what I was looking for, and it worked perfectly. Sometimes the obvious answer is the correct one. I was looking for it to be too complicated ...

Ken
Photo of J.

J., Official Rep

  • 7,470 Points 5k badge 2x thumb
No problem! We do try to provide a simple solution whenever possible, but make sure that Skuid is flexible enough to cover as many use cases as possible (hence both the long and short ways of merging model rows). By the way, Zach recently did a dev talk on our merge syntax. He covered a lot (if not all) that you can do with it.