Skip to main content

I’m trying to create a simple Model Lookup formula with page with two models, ContactData and a task model.  It won’t return any values.  What am I doing wrong?

MODEL_LOOKUP(“ContactData”,“Household”,“ID”,{{WhoId}})

What is the setup of your underlying Salesforce Organization? Have you checked the Schema Builder?


I think they are linked correctly because I am able to pull the Who.ID in the task object correctly in a separate field, and it matches the correct contact ID.


The schema builder image is below.


Allison, I’m relatively certain your problem is that you’ve used “ID” instead of “Id” in your MODEL_LOOKUP formula, which is very sensitive to syntax in my experience. Give that simple change a try and see if it helps.


Thanks Michael.  I was using “ID” but changed to “Id” and same results.  Any other ideas?


Could you post your XML so I can take a look?


The XML would be helpful


MODEL_LOOKUP("ContactData","Email","Id",{{WhoId}})








TODAY
LAST_N_DAYS:10000




TODAY






































Contact



Due Date



Set By



                                    </field>
<field id="ContactEm" hideable="true" uniqueid="fi-3UTP8d-639" valuehalign="" type="">
<label>Email</label>
<renderconditions logictype="and" onhidedatabehavior="keep"/>
<enableconditions/>
</field>
<field type="COMBO" hideable="true" uniqueid="fi-2wVXJu-828" valuehalign="">
<label>Emails-1,2,3. Phone 1,23, Last WMR</label>
<template>
<contents/>
</template>
</field>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
<searchfields/>
<filters>
<filter type="daterange" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="auto" labelmode="no" conditionfield="ActivityDate"/>
<filter type="toggle" filteroffoptionlabel="New Filter" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" labelmode="auto" label="TODAY (w/ past)">
<effects>
<effect action="activate" value="" condition="LowTaskTodayFilter"/>
</effects>
</filter>
</filters>
</skootable>
</components>
</panel>
</panels>
<renderconditions logictype="and"/>
</panelset>
</components>
</pageregioncontent>
</pageregioncontents>
<components/>
<resources>
<labels/>
<css/>
<javascript/>
</resources>

I think your problem is that your ContactData model is AFTER your Scheduling model, so the data hasn’t loaded in time for the MODEL_LOOKUP formula to grab it. I switched the order and I think it worked for me.


Hmmm, I tried switching and still not getting anything.


I see you have an Email2 field. Are you completely certain you have data in the Email field you’re referencing in the MODEL_LOOKUP field?


Yes, and I’ve adjust the field pulled to another and still nothing coming through.


What are you hoping will show in the lookup field?


The email address from the matching contact object.


Allison,

Can you share the XML for the ContactData and Household models?

Thanks,

Bill


Yes, they are above.  Do you need additional details?


Allison,


My mistake on the XML request. I jumped to the last comment and missed it. Take a look at your XML for the formula field. The XML definition does not look right.


Here is a simple working page that you can try in your org:


<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Task">
<models>
<model id="Task" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Task" type="">
<fields>
<field id="Subject"/>
<field id="CreatedDate"/>
<field id="WhoId"/>
<field id="Who.Name"/>
<field id="WhoEmail" uionly="true" displaytype="FORMULA" label="WhoEmail" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">
<formula>MODEL_LOOKUP("ContactData","Email","Id",{{WhoId}})</formula>
</field>
</fields>
<conditions/>
<actions/>
</model>
<model id="ContactData" limit="200" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
<fields>
<field id="Name"/>
<field id="Email"/>
</fields>
<conditions>
<condition type="modelmerge" value="" field="Id" operator="=" state="" model="Task" enclosevalueinquotes="true" mergefield="WhoId" novaluebehavior="noquery" fieldtargetobjects="Contact,Lead"/>
</conditions>
<actions/>
</model>
</models>
<components>
<pagetitle model="Task" uniqueid="sk-3cu4K8-78">
<maintitle>
<template>{{Model.labelPlural}}</template>
</maintitle>
<subtitle>
<template>Home</template>
</subtitle>
<actions>
<action type="savecancel" uniqueid="sk-3cu4K6-77"/>
</actions>
</pagetitle>
<skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Task" mode="read" allowcolumnreordering="true" uniqueid="sk-3cu4KR-88">
<fields>
<field id="Subject" hideable="true" allowordering="true" uniqueid="fi-3cu3Ty-238"/>
<field id="CreatedDate" hideable="true" allowordering="true" uniqueid="fi-3cu3Ty-239"/>
<field id="WhoId" hideable="true" uniqueid="fi-3cu9Fg-121" valuehalign="" type=""/>
<field id="WhoEmail" hideable="true" uniqueid="fi-3cuqFr-307" valuehalign="" type=""/>
</fields>
<rowactions>
<action type="edit"/>
<action type="delete"/>
</rowactions>
<massactions usefirstitemasdefault="true">
<action type="massupdate"/>
<action type="massdelete"/>
</massactions>
<views>
<view type="standard"/>
</views>
</skootable>
</components>
<resources>
<labels/>
<css/>
<javascript/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Thanks,


Bill


Thanks Bill.  I updated the code and the page works but still doesn't produce any data :(


Allison,

I don’t think your ContactData model is getting any contact records that would match a WhoId in you task model.  Install my page and take a look at the condition on the ContactData model.  I am getting contact records where the Id of the Contact is ‘IN’ the set of WhoId returned by the task model.  I am guaranteeing some matches.

You can verify this manually if you view the models in your console or add the Who.Id field to your table and add another table to display the contact Id’s.

Thanks,

Bill


Thanks Bill.  I appreciate all the help but something still isn’t matching up correctly.  I’m having the table also just display the WhoIDs.  I can then go and manually search for them on a different contact table and find the data manually.  The lookup feature just isn’t working (or I’m not doing something right! 😕


The really frustrating thing is that I can get this to work in the basic Salesforce reporting menu too.  Not very often that SF native is easier to figure out than Skuid!


Allison,

I recommend that you install my sample page and see if it returns email addresses.

I think what is happening is that your ContactData model is not returning enough records to find a match in your Task model.  You could increase the record limit on your ContactData model to 1000 and see if you get some matches.  The better option is to add a condition to your ContactData model to return contacts who are in the list of Tasks that you are viewing (that is where the ContactData contact Id matches the WhoId from your Task model).

Thanks,

Bill


Reply