Issue with Model Lookup

  • 2
  • Question
  • Updated 1 year ago
  • Answered
Hi Having issues building a Formula with model lookup from another Agg Model

Here's my scenario:

I have 2 Aggregate Models: 1 Named 'TimesheetentryAgg' the other named: 'FundingAgg'

I want to use the result UI Field from 'TimesheetentryAgg' named 'TotalPaid' (this ui field is a formula field adding 2 Sum aggregations) for a calculation on model: 'FundingAgg'

So on 'FundingAgg' i created a UI Only field with this formula , just to see if value would show:
MODEL_LOOKUP("timesheetEntryAgg","TotalPaid")

And field return empty.

Note that the order of model load is correct, Timesheet is loaded before Funding

As well did not add 3rd and 4th optional parameter to model lookup formula , as from what i read on training guide, not always necessary and if i understood correctly an Agg model only has 1 row? and needed to use not sure what i can use as these 2 models have not much in common...

I would appreciate any help

Thx
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 1 year ago

  • 2
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Dave,

I tried this in my developer org. that is on Skuid 10.0.4.  What you are trying to do works.  I have included my XML that does a count of tasks by WhoId and calculates a percentage.

In looking at your post, I noticed that in your 3rd paragraph your model name is  'TimesheetentryAgg'.

In your 5th paragraph, you show your model lookup as MODEL_LOOKUP("timesheetEntryAgg","TotalPaid").

Notice that the 't' in your model lookup is NOT capitalized.  That may be your problem.  I would verify that your first model has a row in it and then carefully check that your model name and model field in your model lookup UI field match your first aggregate model.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
    <models>
        <model id="TotalTasks" limit="" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Task">
            <fields>
                <field id="Id" name="countIdTask" function="COUNT"/>
            </fields>
            <conditions/>
            <actions/>
            <groupby method="simple"/>
        </model>
        <model id="TasksByWhoId" limit="" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Task">
            <fields>
                <field id="Id" name="countIdWho" function="COUNT"/>
                <field id="Percentage" uionly="true" displaytype="FORMULA" label="Percent of Total" ogdisplaytype="TEXT" readonly="true" returntype="PERCENT" precision="3" scale="2">
                    <formula>{{countIdWho}}/MODEL_LOOKUP("TotalTasks","countIdTask")*100</formula>
                </field>
            </fields>
            <conditions/>
            <actions/>
            <groupby method="simple">
                <field id="WhoId" name="whoId"/>
                <field id="Who.Name" name="whoName"/>
            </groupby>
        </model>
    </models>
    <components>
        <pagetitle model="TotalTasks" uniqueid="sk-3wyOpP-175">
            <maintitle>Total Tasks:  {{$Model.TotalTasks.data.0.countIdTask}}</maintitle>
            <actions/>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" alwaysresetpagination="false" createrecords="false" model="TasksByWhoId" buttonposition="" mode="readonly" allowcolumnreordering="true" responsive="true" uniqueid="sk-3wyj7V-226">
            <fields>
                <field id="Who.Name" name="whoName" hideable="true" uniqueid="fi-3wykkT-236"/>
                <field id="Id" name="countIdWho" hideable="true" uniqueid="fi-3wykkT-237" valuehalign="" type="">
                    <label>Number of Tasks</label>
                </field>
                <field id="Percentage" hideable="true" uniqueid="fi-3wz8Vf-402" decimalplaces="" valuehalign="" type=""/>
            </fields>
            <rowactions/>
            <massactions usefirstitemasdefault="true"/>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Hi Bill,

Thank you for your help. 

Unfortunately the typo was in post only... i wrote it in a hurry , sorry

I looked at your example, ty for providing it and it seems liek u said i'm doing things correctly.

So still cannot figure out issue :(  

So here's SS from every step , maybe it will help?







I'm not very good at working with console, but trying to lookup model to see if UI field has value , but do not see it at all there (is it normal?)



Thank you!
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
I found the culprit!

Instead of just looking at the builder page, I decided to test your page Bill, once i made some changes on it to work on my org

and realized it did not return results as well....

You mentioned u tested it on 10.0.0.4 , so tested it on my sandbox on which i was testing latest version and it worked!

My Production org is still under 8.15.14 ... not sure why it's not working on this version, but in case someone has same issue, here's the answer

Don't put off too long updating skuid like me :D (i try to not update too often as it takes me a lot of time to test all of our pages and other items that uses skuid to make sure no crucial bug and all working as it should , hope SF allows rollbacks soon!)

Does anyone know if this is a new feature that came in after 8.15 version?

Thx
(Edited)