Skip to main content

I want to total the sum fields from 2 models in a U-I Field.

The first aggregation


The second aggregation


My U-I field


Is my formula wrong?

Bill,

Your formula is adding the first rows of the aggregate models together. If your groupings are rollup, then you need to access the LAST rows of those models to get the SUM of each.

This is a little tricky, but if you have a ‘category’ field on each model, you can access if with something like this:

MODEL_LOOKUP(“Member_DNA_Point_Tracker”, “YourGroupingField”, “sumPointsc”, null)

Just going by memory here. I may have gotten the two middle arguments backwards… check the documentation to be sure.


I am not sure this matter, but I have no groupings just a count for how many there are for 1 field “Points” in each model) To test I have the fields like this


It shows like this:


Which is correct. So, cannot figure how to add the single field in each model together.


Bill,

You can test your global merge syntax the same way.

Make sure you have your formula set to return a number.


I did not have it as a number. If I do not want to do any addition and just want to get that 1 field from the Member_DNA_Point Tracker.

I have tried this

{{$Model.Member_DNA_Point_Tracker.sumPointsc}}

and this

{{$Model.Member_DNA_Point_Tracker.data.sumPointsc}}

and this

{{$Model.Member_DNA_Point_Tracker.data.0.sumPointsc}}

and this

{{$Model.Member_DNA_Point_Tracker.0.sumPointsc}}


Bill,

Put the third in a rich text component and see if it displays the right value in runtime:
{{$Model.Member_DNA_Point_Tracker.data.0.sumPointsc}}


Ok. I did this:


and I got this


Which is correct.

But now what?


I found that you need to include the merge fields in VALUE(xxx) for this to work.
Try VALUE(xxx) + VALUE(yyy).  
ABS(xxx) + ABS(yyy) would also work.
If that doesnt work, try VALUE(VALUE(xxx)+VALUE(yyy))


I will try this.  Does the model that does the addition need to be below the model fields being added?


Don’t think so.


Does not work. Any other ideas?


Bill,

I think Mansour is right.

Just to confirm, your formula now looks like this?


VALUE({{$Model.Member_DNA_Point_Tracker.data.0.sumPointsc}}) + VALUE({{$Model.Person_Point_Tracker.data.0.sumPointsc}})

Yes. That is the formula.  However, when preview with that formula intact the screen show blank  I have created a video just to confirm I have everything correct.
https://drive.google.com/file/d/0B409lhd9sYDcR2dVUHR5VXVhdzA/view?pli=1


Just tried it on my end, looks like a bug if you ask me.  This used to work and is now not working anymore.  Rob, Zach any ideas?


Bill,

Do you have any console errors? That’s always the first thing I check with a blank screen.


Here is the console error


What code is the error coming from?

If you reload the page with your console open, you should be able to expand the error and see the call stack. On the right side of the console, you’ll see what the source and line number of the code the call is coming from.


What should I click on here?
bf261c535c04b13ff83ce2752b7c03af48215d8c.jpg


The last link… that will show you the part of the code on your page that is triggering the problem (line 73 of your page).


I have no idea what to do with line 73 code:


skuid.component.factory({“element”: “#sk-page-a04j000000APlCFAA1-cmp-1447353646944-1”,“xmlDefinition”: '<action type=“showPopup” window=“blank” url=“https://dorothy–skuid.na16.visual.force.com/apex/skuid__ui?page=R_Add_Member_DNA”><popup title=“” width=“90%”>A_Temp_CR_Add_Task__cEventAddEmailAddA_Temp_CR_Add_Task__cA_Temp_CR_Add_Task__cMem_Relation_PersonMem_Relation_OrgMem_License_PersonMem_License_OrgMem_PhoneMem_EmailMem_SocialMem_ReferredMem_CR_Open_MemberMem_CR_Open_Member_Contact_RecordMem_CR_Open_PersonMem_CR_Open_LocationMem_CR_Open_OrganizationMem_CR_Closed_MemberMem_CR_CLosed_PersonMem_CR_CalendarMem_OpportunitiesMem_Opportunities_OrganizationMem_Opportunities_LocationMem_Opportunities_PersonMem_EngagementMem_Engagement_OrganizationMem_Engagement_LocationMem_Engagement_PersonMem_Offer_MemberMem_Offer_OrganizationMem_Offer_LocationMem_Offer_PersonMem_DocumentsPhones_ChatterMember_DNA_ListLocation_ListSummary_Location_ListMem_People_at_LocationMem_People_at_OrganizationMem_Location_at_OrganizationMem_MembersMem_Contact_Record_Results&lt;p&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(102, 0, 153); font-family: &apos;comic sans ms&apos;, cursive; font-size: 14px; font-weight: bold;&quot;&gt;Type Wiki&lt;/span&gt;&lt;/p&gt;

MemberAssigned toCompleted byTypeCompletedStatusA_Temp_CR_Add_Task__cA_Temp_CR_Add_Task__cMem_Relation_PersonMem_Relation_OrgMem_License_PersonMem_License_OrgMem_PhoneMem_EmailMem_SocialMem_ReferredMem_CR_Open_MemberMem_CR_Open_Member_Contact_RecordMem_CR_Open_PersonMem_CR_Open_LocationMem_CR_Open_OrganizationMem_CR_Closed_MemberMem_CR_CLosed_PersonMem_CR_CalendarMem_OpportunitiesMem_Opportunities_OrganizationMem_Opportunities_LocationMem_Opportunities_PersonMem_EngagementMem_Engagement_OrganizationMem_Engagement_LocationMem_Engagement_PersonMem_Offer_MemberMem_Offer_OrganizationMem_Offer_LocationMem_Offer_PersonMem_DocumentsPhones_ChatterMember_DNA_ListLocation_ListSummary_Location_ListMem_People_at_LocationMem_People_at_OrganizationMem_Location_at_OrganizationMem_MembersMem_Contact_Record_Results&lt;p&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(102, 0, 153); font-family: &apos;comic sans ms&apos;, cursive; font-size: 14px; font-weight: bold;&quot;&gt;Enter Task&lt;/span&gt;&lt;/p&gt;

ObjectiveDateAssigned ToMemberStatusTypeA_Temp_CR_Add_Task__c&lt;p&gt;&lt;span style=&quot;font-size:14px;&quot;&gt;&lt;strong&gt;&amp;nbsp;Are you sure you want to delete this CR Event?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;

A_Temp_CR_Add_Task__cA_Temp_CR_Add_Task__c&lt;p&gt;&amp;nbsp;&lt;span style=&quot;font-size: 13.3px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(102, 0, 153); font-family: &apos;comic sans ms&apos;, cursive; font-size: 14px; font-weight: bold;&quot;&gt;Enter Event/Meeting&lt;/span&gt;&lt;/p&gt;

A_Temp_CR_Add_Task__cMem_Relation_PersonMem_Relation_OrgMem_License_PersonMem_License_OrgMem_PhoneMem_EmailMem_SocialMem_ReferredMem_CR_Open_MemberMem_CR_Open_Member_Contact_RecordMem_CR_Open_PersonMem_CR_Open_LocationMem_CR_Open_OrganizationMem_CR_Closed_MemberMem_CR_CLosed_PersonMem_CR_CalendarMem_OpportunitiesMem_Opportunities_OrganizationMem_Opportunities_LocationMem_Opportunities_PersonMem_EngagementMem_Engagement_OrganizationMem_Engagement_LocationMem_Engagement_PersonMem_Offer_MemberMem_Offer_OrganizationMem_Offer_LocationMem_Offer_PersonMem_DocumentsPhones_ChatterMember_DNA_ListLocation_ListSummary_Location_ListMem_People_at_LocationMem_People_at_OrganizationMem_Location_at_OrganizationMem_MembersMem_Contact_Record_ResultsA_Temp_CR_Add_Task__cMem_View_CR_Memberz&lt;p&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(102, 0, 153); font-family: &apos;comic sans ms&apos;, cursive; font-size: 14px; font-weight: bold;&quot;&gt;Enter Event/Meeting&lt;/span&gt;&lt;/p&gt;

StartEndObjective/ScheduleMemberWill there be other Members?Assigned toWill there be other Member Agents / Users?<field id="Temp_Document_to_Upl


Hmm, yeah. Not helpful.

Not sure what to tell you. Perhaps skuid can take a look under the hood at what’s causing the error.

Alternatively, you can try reverting to a page version that doesn’t have the error, to try to isolate what change caused the problem.


Oooh so much code. So much help.


Enclosed below is some page XML for a test jig. It adds together the count of leads and contacts in your org.


  • The first set of models do this addition for aggregate models that have NO grouping. This is the easy solution (and is what I read you are trying to do above)

  • The second set of models do this addition for models that DO Have grouping (but the blank values in the grouping field have been removed). Here the "roll up" grouping method is critical.


Run this test page in your org and let me know what happens. Oh btw - what version of skuid are you on?
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true"> <models> <model id="leads" limit="" query="true" createrowifnonefound="false" adapter="" type="aggregate" sobject="Lead"> <fields> <field id="Id" name="countId" function="COUNT"/> </fields> <conditions/> <actions/> <groupby method="simple"/> </model> <model id="contact" limit="" query="true" createrowifnonefound="false" adapter="" type="aggregate" sobject="Contact"> <fields> <field id="Id" name="countId" function="COUNT"/> </fields> <conditions/> <actions/> <groupby method="simple"/> </model> <model id="UIOnlyModel" limit="1" query="true" createrowifnonefound="false" adapter="" type="" sobject="User"> <fields> <field id="TotalNonGroupedPeople" uionly="true" displaytype="FORMULA" label="Total People" readonly="true" returntype="DOUBLE" precision="9" scale="2"> <formula>VALUE({{$Model.leads.data.0.countId}})+VALUE({{$Model.contact.data.0.countId}})</formula> </field> <field id="TotalGroupedPeople" uionly="true" displaytype="FORMULA" readonly="true" returntype="DOUBLE" precision="9" scale="2" label="Grouped People"> <formula>MODEL_LOOKUP("leadsByCat","countId","leadSource",null)+MODEL_LOOKUP("contactByCat","countId","leadSource",null)</formula> </field> </fields> <conditions> <condition type="userinfo" value="" field="Id" operator="=" enclosevalueinquotes="true" userinfotype="userid"/> </conditions> <actions/> </model> <model id="leadsByCat" limit="" query="true" createrowifnonefound="false" adapter="" type="aggregate" sobject="Lead"> <fields> <field id="Id" name="countId" function="COUNT"/> </fields> <conditions> <condition type="blank" value="null" field="LeadSource" operator="!=" enclosevalueinquotes="false"/> </conditions> <actions/> <groupby method="rollup"> <field id="LeadSource" name="leadSource"/> </groupby> </model> <model id="contactByCat" limit="" query="true" createrowifnonefound="false" adapter="" type="aggregate" sobject="Contact"> <fields> <field id="Id" name="countId" function="COUNT"/> </fields> <conditions> <condition type="blank" value="null" field="LeadSource" operator="!=" enclosevalueinquotes="false"/> </conditions> <actions/> <groupby method="rollup"> <field id="LeadSource" name="leadSource"/> </groupby> </model> </models> <components> <pagetitle model="leadsByCat" uniqueid="sk-6HYX4-419"> <maintitle>Aggregate Models With NO Groupings</maintitle> <actions/> </pagetitle> <panelset type="custom" uniqueid="sk-6Ggxz-261" scroll=""> <panels> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="leads" buttonposition="" mode="readonly" uniqueid="sk-6Gl2C-280" emptysearchbehavior="query"> <fields> <field id="Id" name="countId" valuehalign="" type=""> <label>Leads</label> </field> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="contact" buttonposition="" mode="readonly" uniqueid="sk-6Gla9-292" emptysearchbehavior="query"> <fields> <field id="Id" name="countId" valuehalign="" type=""> <label>Contacts</label> </field> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="UIOnlyModel" buttonposition="" mode="readonly" uniqueid="sk-6Gfer-249" emptysearchbehavior="query"> <fields> <field id="TotalNonGroupedPeople" decimalplaces="" valuehalign="" type=""/> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> </panels> </panelset> <pagetitle model="leadsByCat" uniqueid="sk-6Hfs1-430"> <maintitle>Aggregate Models With Groupings</maintitle> <actions/> </pagetitle> <panelset type="custom" uniqueid="sk-6HlpW-436" scroll=""> <panels> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="leadsByCat" buttonposition="" mode="readonly" uniqueid="sk-6HpTk-451" emptysearchbehavior="query"> <fields> <field id="LeadSource" name="leadSource"/> <field id="Id" name="countId"/> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="contactByCat" buttonposition="" mode="readonly" uniqueid="sk-6Hpuo-457" emptysearchbehavior="query"> <fields> <field id="LeadSource" name="leadSource"/> <field id="Id" name="countId"/> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> <panel width="33.3%"> <components> <skootable showconditions="true" showsavecancel="false" showerrorsinline="true" searchmethod="server" searchbox="false" showexportbuttons="false" pagesize="all" createrecords="false" model="UIOnlyModel" buttonposition="" mode="readonly" uniqueid="sk-6JBLP-647" emptysearchbehavior="query"> <fields> <field id="TotalGroupedPeople" decimalplaces="" valuehalign="" type=""/> </fields> <rowactions/> <massactions usefirstitemasdefault="true"/> <views> <view type="standard"/> </views> <searchfields/> </skootable> </components> </panel> </panels> </panelset> </components> <resources> <labels/> <javascript/> <css/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> </skuidpage>