I’m having a problem when I have a model that I set to late load (not on page load). I’m setting a condition in a snippet, and then tell the model to update … and that works just fine. But other models that have relationships to the first model (such as a primary model of Lead, and a secondary related model with a condition of Task.WhoId == Lead.Id) do not update their content (they are also set to late load).
I’m making sure to call updateData, I’m waiting for Lead to load before trying to load Task, and yet I still find the Task object doesn’t work. If I switch to setting the condition manually (where I simple call Model.setCondition and use Lead.datas0].Id from the Lead model) it works fine.
I’ve created a very simple example of this problem. Note that I am using RC3 of Superbank … and I’ve not tried it on any other release. This sample code uses a hard-coded Id of a Lead object - so you will need to adjust that for your own Lead objects.
Any thoughts on what I’m doing wrong?
Thanks,
- Chris
<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true"> <models>
<model id="Lead" limit="20" query="false" createrowifnonefound="false" sobject="Lead" doclone="" type="">
<fields>
<field id="Id"/>
<field id="Name"/>
</fields>
<conditions>
<condition type="fieldvalue" value="" field="Id" operator="=" novaluebehavior="noquery" state="filterableon" inactive="false" name="Id" enclosevalueinquotes="true"/>
</conditions>
<actions/>
</model>
<model id="Task" limit="20" query="false" createrowifnonefound="false" sobject="Task" doclone="" type="">
<fields>
<field id="CreatedDate"/>
<field id="CallType"/>
<field id="Subject"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="WhoId" operator="=" model="Lead" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="noquery" state="filterableon" inactive="false" name="WhoId"/>
</conditions>
<actions/>
</model>
</models>
<components>
<basicfieldeditor showheader="true" showsavecancel="false" model="Lead" buttonposition="" mode="readonly" layout="">
<columns>
<column width="100%">
<sections>
<section title="Section A" collapsible="no">
<fields>
<field id="Name" valuehalign="" type=""/>
</fields>
</section>
</sections>
</column>
</columns>
</basicfieldeditor>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="false" model="Task" buttonposition="" mode="readonly">
<fields>
<field id="CreatedDate" valuehalign="" type=""/>
<field id="CallType" valuehalign="" type=""/>
<field id="Subject" valuehalign="" type=""/>
</fields>
<rowactions/>
<massactions usefirstitemasdefault="true"/>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<javascript>
<jsitem location="inline" name="setupId" cachelocation="false" url="">var $ = skuid.$;
$(document.body).one('pageload',function() {
var lead = skuid.model.getModel('Lead');
var task = skuid.model.getModel('Task');
var leadCondition = lead.getConditionByName('Id');
var taskCondition = task.getConditionByName('WhoId');
lead.setCondition(leadCondition, '00Q70000011wqoiEAA', false);
lead.updateData((function(){
// If the following line is added, it works fine (which even loads the Id from the lead model)
// task.setCondition(taskCondition, lead.dataC0].Id, false);
task.updateData();
}));
});
</jsitem>
</javascript>
<css/>
</resources>
</skuidpage>