Use new record ID in condition on another model

Hi, Elissa,
It looks like you’re doing everything right so far. However, Skuid is not updating your MedRecs model the page is refreshed. In the words of Ben Hubbard, “Unfortunately as of yet, Skuid will not automatically update “Field from another Model” type conditions when their source model is updated” (see this post… it might be helpful to you). There is a workaround, but it’s a little more complicated.

What you have to do:

  • On your MedRecs model, remove your condition and add a new one that is filterable and off by default. Give your condition a name, and leave the value field empty.
  • Create a custom button for your users to click after entering Shipment information. This button will save the Shipment model, set the MedRecs condition’s value to the Ship_From__c value from the Shipment model, and bring in data to the MedRecs model. 
  • The snippet for your custom button should look something like this:

var $ = skuid.$; //get models and conditions var shipmentModel = skuid.model.getModel('Shipment'); var medrecModel = skuid.model.getModel('MedRecs'); var medrecCondition = contactModel.getConditionByName('MyMedRecCondition'); //After the user enters data on the Shipment, save Shipment model shipmentModel.save({callback: function(){ //get the new shipment var shipment = shipmentModel.getFirstRow(); //Set the MedRecs model's condition to contain the AccountId from the new Shipment, and refresh the model medrecModel.setCondition(medrecCondition, shipment.AccountId); medrecModel.activateCondition(medrecCondition); medrecModel.updateData(); }});


See how this works!
Emily