file component not responding to model condition update

I have a table of Appointments on the model AppointmentInteraction_Table. I have a Row Action on that table runs multiple actions: Deactivates model conditions for the AppoinmentInteraction_Detail model and the Interaction_Attachments model, then activates and sets the value of those conditions to the appropriate id, and finally Queries both models.

Here’s my table:

                  <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="10" createrecords="false" model="AppointmentInteraction_Table" buttonposition="" mode="read">                     <fields>
                        <field id="Date__c" valuehalign="" type="" readonly="true" allowordering="true"/>
                        <field id="Interaction_Purpose__c" valuehalign="" type="" readonly="true" allowordering="true">
                           <label>Appointment Purpose</label>
                        </field>
                        <field id="Notes__c" valuehalign="" type="" readonly="true"/>
                     </fields>
                     <rowactions>
                        <action type="multi" label="See Report" icon="fa-arrow-down">
                           <drawer title="Drawer Area" width="800" closehandle="true">
                              <components/>
                           </drawer>
                           <actions>
                              <action type="deactivateCondition" model="AppointmentInteraction_Detail" condition="InteractionId"/>
                              <action type="deactivateCondition" model="STD_Tests" condition="InteractionID"/>
                              <action type="deactivateCondition" model="Attachment_Interaction" condition="ParentId"/>
                              <action type="setCondition" model="AppointmentInteraction_Detail" condition="InteractionId" value="{{Id}}"/>
                              <action type="setCondition" model="STD_Tests" condition="InteractionID" value="{{Id}}"/>
                              <action type="setCondition" model="Attachment_Interaction" condition="ParentId" value="{{Id}}"/>
                              <action type="requeryModels" behavior="standard">
                                 <models>
                                    <model>AppointmentInteraction_Detail</model>
                                    <model>Attachment_Interaction</model>
                                    <model>STD_Tests</model>
                                 </models>
                                 <onerroractions>
                                    <action type="blockUI" message="There was an error." timeout="1500"/>
                                 </onerroractions>
                              </action>
                           </actions>
                        </action>
                     </rowactions>
                     <massactions usefirstitemasdefault="true"/>
                     <views/>
                     <searchfields/>
                     <actions defaultlabel="Global Actions" defaulticon="sk-icon-magic" usefirstitemasdefault="true"/>
                  </skootable>

Underneath the table I have a tabset with several tabs of Field Editor components. These are working great. The field editors show the data from the correct row when I use the Row Action.

However, on one of my tabs I have a File component, which should allow the user to attach a file to the Interactions object (not a particular field) which is behind the AppointmentInteraction_Detail model (and the AppointmentInteraction_Table). The problem is the File component doesn’t seem to update to a new row on the model after I use the Row Action. Whichever row I attach a file to the first time after page load, it will always attache files to that row.

Here are the relevant parts of the AppointmentInteraction_Detail model:

      <model id="AppointmentInteraction_Detail" limit="1" query="false" createrowifnonefound="false" sobject="Interaction__c" forview="true" doclone="" type="">         <fields>
            ...
         </fields>
         <conditions>
            <condition type="param" value="id" field="Patient_Case__c" operator="=" mergefield="Id" novaluebehavior="deactivate" enclosevalueinquotes="true"/>
            <condition type="fieldvalue" value="Appointment" enclosevalueinquotes="true" field="Interaction_Category__c"/>
            <b><condition type="fieldvalue" value="" field="Id" state="filterableoff" inactive="true" name="InteractionId" operator="=" mergefield="Id" novaluebehavior="deactivate" enclosevalueinquotes="true"/>
</b>         </conditions>
         <actions/>
      </model>

Any ideas on what I’m doing wrong here? I’m pretty new to Skuid, so I’m assuming this is a user error.

You may have to set the querying seperately. First AppointmentInteraction_Detail and then Attachment_Interaction.

Also, why not set Attachment_Interaction ParentID to be AppointmentInteraction_Detail model? That way you wouldn’t have to set it or anything.


Thanks for the suggestions.

Querying separately doesn’t seem to make a difference. The file ends up attached to whatever record I first ran the row action on.

Also, when I update the condition as you suggested, the model returns all of the attachments on that object, not just the ones associated with the row. Weird.

Odd. Can you provide a video?

Here’s a video from a preview. Does that help?







As a follow-up, when I change the conditions on the Attachment_Interaction ParentID as suggested…


I get every file that has been attached to an interaction. It’s as if the condition on the model doesn’t exist. No matter which row action I click, the table to files looks like the below…

Very odd. From what I can tell the, the PageTitle component is the AppointmentInteraction_Detail  model. This tells me that the model is updating as requested. Further to this, the ParentID on the Attachment_Interaction is correctly set as the table components updates properly.

The one thing that isn’t working is the fact that attachments go to the first appt. that has been selected in the AppointmentInteraction_Detail.

  1.  What are the advanced settings on the AppointmentInteraction_Detail model?
  2. What Parent Model is the File Component set to?

You’re correct on all. Answers:

1. Here are the advanced settings… 


2. AppointmentInteraction_Detail

Hey Jim,

I think we’re looking at 2 different issues here.

1. The File component not reacting correctly to a change in its associated model.

2. Field from another model conditions not working as expected when a change is made to the source model.

I’ll start with the first issue pertaining to the file component.

I did some investigating and it looks like the file component is not correctly reacting to changes in its associated model.  The first time it is rendered it remembers the id that was associated with it at the time and doesn’t update it when the model changes.  That’s why it’s always attaching uploads to the item that was first clicked.

A quick hacky workaround would be to run an inline snippet at the end of your actions to manually refresh all file components on the page like this.

var params = arguments[0], <br>&nbsp; &nbsp; $ = skuid.$;<br>$.each(skuid.component.getByType('file'),function(){<br>&nbsp; &nbsp; this.render();<br>});

However, you’d want to remove this snippet when a version of Skuid came out that fixed this issue.  I’ll mark this down as a bug.

The second issue is a bit more straightforward.  Skuid always processes model merge type conditions server side.  So when doing a “Query Models” action from the action framework, you have to include the reference model in the list of models to query.  Otherwise, when Skuid tries to get a row from the reference model, it won’t exist and it will run your “If no row in Source Model” behavior.  In your case, it’s just removing that condition and returning all Attachment rows.

Let me know if this helps or if you need additional clarification.

The snippet works perfectly.

I still wasn’t able to get the field from another model conditions to work correctly. Ideally, I would only need to use the row action to update the condition on the AppointmentInteraction_Detail model, and have the STD_Tests and Attachment_Interaction model conditions reference the ID from the AppointmentInteraction_Detail model. But I kept getting bizarre results, no matter what models I queried after the row action. In my last attempt, the table displaying uploaded files would never update without refreshing the entire page.

I switched back to making filterable conditions and using the row action to activate and set values for the conditions on all three models, and it’s working fine that way.

Ah, I just read the related question from Pat here: https://community.skuid.com/t/condition-value-changed-do-i-have-to-requery
It seems I need to query all the relevant models in the same Query Model(s) action?


Yeah, they have to be in the same individual action or it won’t work.