Model conditions not applied correctly on create new row from table drawer.

  • 1
  • Problem
  • Updated 3 years ago
  • Solved
Maybe I'm doing something wrong here, but I thought this worked in the past. It's a bit of a long story, so... 5min video.


Basically, using javascript to create a row in a drawer. Opening the drawer set's the condition for the drawer model's parent. That's working fine. But when I use createRow() from within the drawer, the condition to identify the model's parent gets reset to the first row in the parent table, instead of the row for the currently open drawer.

Hopefully the video makes more sense than that just did.

Help?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
Hey Matt -

Unfortunately, there are some things going on in your app/code that aren't shown in the video (eg. what is the value of datarow in the call to makeCase) so it's difficult to say exactly what might be going on here.

One word of caution on the approach you are taking here is that the following scenario could occur:

1) User opens Drawer for Row #2 - Condition gets set to ID of row #2
2) User opens Drawr for Row #1 - Conditions gets set to Id of row #1
3) User clicks create new button inside of drawer for #2 - Row will (should) be created for Id of row in #1 since that was the last time the condition was set

Given this, you likely want to change your approach to not rely on the model conditions and instead, explicitly set the appropriate value to ensure that the new case gets created against the correct patient.  To do this, grab the Id of the row in context and apply it in your additionalConditions property in the call to createRow.

Now, all that being said, the strange behavior you are experiencing is a little concerning.  It could be a skuid bug or it could be something in your code.  Difficult to say without more visibility to your code, etc.  If you can put together a repro of the scenario using standard objects I'd be happy to throw it in to a DE org on my side and take a closer look.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Thanks, Barry. Your word of caution was instructive. Grabbing the row in context and manually setting the value along with the rest of the additionalConditions was an easy fix.

Not sure if there's any kind of bug here, but if there is, it's probably something unique enough to not bother with.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,086 Points 10k badge 2x thumb
Glad the change in approach resolved things Matt.  As for the strange behavior/bug, if you decide to circle back and try to isolate, let me know.  There definitely is a problem there (either skuid side or custom code) and it's likely to manifest itself again.