Contact Model Based on Event WhoId (for Account View)

  • 1
  • Question
  • Updated 3 years ago
  • Answered
On our Account Skuid View page, we have a model for events, nothing fancy. In our sales cycle, we have openers create events for closers that allows them to qualify and determine whether or not they will "accept" opportunities.

Here's a screenshot of what the scheduled event might look like from an AE's perspective:

The fields in the top section are from the Events model; fields on the bottom are from the Account. Our problem is that we're mostly limited to those objects in this pop-up (or other objects related to the account, oftentimes with multiple records).

But because there is important information on the Contact record identified by the WhoId on this Event, we would love to be able to view that info in this pop-up.

Question: Would we be able to create a Contact model that is only the Contact referenced by the WhoId for a given Event? That would be our ideal solution. I know the other two ways to view the Contact info would be:
  • go to the Contact page itself (or open up a pop-up with their info)
  • put the fields we want on the Account itself (not ideal)
Any ideas would be great, thanks!
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Dear Dylan, this is totally doable. I think the best and easiest way is to create an "Event Contact" model where Contact Id = the WhoId field from the Events model. Make sure to set this model to *not* load data on page load.  Then you can use the actions framework to query the model when the popup is opened. (You may also have to add an action before that to set the value of the model Id condition to the Id of the Event in context if there are multiple events on your mother page, as I'm assuming there are.)

That's an overview, please let me know if you need more details, and let me know a little bit more about the context of the page from which you're opening the popup (I'm assuming it's an account detail view with a list of events).
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb
Hi Anna,

Thanks for the response. Your correct about the situation - I have a tab on my Account detail with a list of events, and there is a pop-up next to each event that I can open. For whichever event a user opens, I would like to activate the Contact model referenced in the Event WhoId.

I think I'll need some clarification on using the actions framework to query the model. Would I be correct in assuming that the initiating event to trigger the action would be set on the Events model? And then in that case, I'm not sure would be a valid event trigger. Perhaps when I click the pop-up button it saves the Events model (even if there are no unsaved changes), and then that would trigger the action of querying the EventContact model where the ID = Event WhoId?
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb
One other thing, which is somewhat of a separate issue, but will still cause me issues is the functionality of the field editors in the pop-up. For whatever reason, I'm only able to see Field Editors that are of the Event model:



In the above screenshot there are 3 field editors, with the Models as Events, Account, Events. None of the sections/columns/fields seem to appear in non-Events model Field Editors, but the save/cancel buttons will display.

I've never seen this before and am wondering if this has to do with the fact that the pop-up is Events model data only, and the only way to look up Account (or ideally in this case, Contact) data is using this method?

Does that make sense?
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Okay, lets see.

(A) It seems like those field editors may not be showing up because there's no data in their models, for example if there is no contact connected with that particular event.  

(B) In this case actions are set not on the models, but on the row action:
  1. To set up the Contact model, uncheck load model data on page load in model properties. Then create a condition where Contact Id is filterable default off. (You don't have to worry about the value because we'll set it later)
  2. Change the popup row action to the run multiple actions type, if it's not that way already. (Don't worry, your popup should be saved under actions).
  3. Click Actions. Add an action to Activate and Set the Value of the Contact Id condition to {{WhoId}} (this brings in the whoid from that event row).
  4. Add another action to Query the contact model. 
  5. Your Show popup action should be last. Then you can go in and configure the popup.
(Edited)
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
Here's a sample page I made to check/verify this process: 

<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Account">   <models>
      <model id="Account" limit="1" query="true" createrowifnonefound="false" sobject="Account">
         <fields>
            <field id="Name"/>
            <field id="CreatedDate"/>
         </fields>
         <conditions>
            <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
         </conditions>
         <actions/>
      </model>
      <model id="Event" limit="20" query="true" createrowifnonefound="false" sobject="Event" doclone="" type="">
         <fields>
            <field id="Subject"/>
            <field id="Description"/>
            <field id="Activity_date_end_for_Calendar__c"/>
            <field id="Activity_date_start_for_Calendar__c"/>
            <field id="WhoId"/>
            <field id="Who.Name"/>
         </fields>
         <conditions>
            <condition type="modelmerge" value="" field="WhatId" operator="=" model="Account" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
         </conditions>
         <actions/>
      </model>
      <model id="Contact" limit="20" query="false" createrowifnonefound="false" sobject="Contact" doclone="" type="">
         <fields>
            <field id="Name"/>
            <field id="Title"/>
         </fields>
         <conditions>
            <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Id" state="filterableoff" inactive="true" name="Id"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Account">
         <maintitle>
            <template>{{Name}}</template>
         </maintitle>
         <subtitle>
            <template>{{Model.label}}</template>
         </subtitle>
         <actions>
            <action type="delete"/>
            <action type="clone"/>
            <action type="share"/>
            <action type="savecancel" window="self"/>
         </actions>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Account" mode="read">
         <columns>
            <column width="50%">
               <sections>
                  <section title="Basics">
                     <fields>
                        <field id="Name"/>
                     </fields>
                  </section>
               </sections>
            </column>
            <column width="50%">
               <sections>
                  <section title="System Info">
                     <fields>
                        <field id="CreatedDate"/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
      <skootable showconditions="true" showsavecancel="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Event" buttonposition="" mode="read">
         <fields>
            <field id="Subject"/>
            <field id="Description"/>
            <field id="Activity_date_end_for_Calendar__c"/>
            <field id="Activity_date_start_for_Calendar__c"/>
            <field id="WhoId"/>
         </fields>
         <rowactions>
            <action type="edit"/>
            <action type="delete"/>
            <action type="multi" label="popup" icon="sk-icon-popup">
               <actions>
                  <action type="setCondition" model="Contact" condition="Id" value="{{WhoId}}"/>
                  <action type="requeryModel" model="Contact" behavior="standard"/>
                  <action type="showPopup">
                     <popup title="New Popup" width="90%">
                        <components>
                           <pagetitle model="Account">
                              <actions>
                                 <action type="multi" label="Save" window="self" icon="sk-icon-save">
                                    <actions>
                                       <action type="blockUI" message="Saving..."/>
                                       <action type="save">
                                          <models>
                                             <model>Event</model>
                                             <model>Contact</model>
                                             <model>Account</model>
                                          </models>
                                       </action>
                                       <action type="closeTopmostPopup"/>
                                       <action type="unblockUI"/>
                                    </actions>
                                 </action>
                                 <action type="multi" label="Cancel" icon="sk-icon-cancel">
                                    <actions>
                                       <action type="cancel">
                                          <models>
                                             <model>Account</model>
                                             <model>Event</model>
                                             <model>Contact</model>
                                          </models>
                                       </action>
                                       <action type="closeTopmostPopup"/>
                                    </actions>
                                 </action>
                              </actions>
                           </pagetitle>
                           <basicfieldeditor showheader="true" showsavecancel="false" model="Event" buttonposition="" mode="read" layout="">
                              <columns>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section A" collapsible="no">
                                          <fields>
                                             <field id="Description"/>
                                             <field id="Subject"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section B">
                                          <fields/>
                                       </section>
                                    </sections>
                                 </column>
                              </columns>
                           </basicfieldeditor>
                           <basicfieldeditor showheader="true" showsavecancel="false" model="Contact" buttonposition="" mode="read" layout="">
                              <columns>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section A" collapsible="no">
                                          <fields>
                                             <field id="Name"/>
                                             <field id="Title"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section B">
                                          <fields/>
                                       </section>
                                    </sections>
                                 </column>
                              </columns>
                           </basicfieldeditor>
                           <basicfieldeditor showheader="true" showsavecancel="false" model="Account" buttonposition="" mode="read" layout="">
                              <columns>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section A" collapsible="no">
                                          <fields>
                                             <field id="Name"/>
                                             <field id="CreatedDate"/>
                                          </fields>
                                       </section>
                                    </sections>
                                 </column>
                                 <column width="50%">
                                    <sections>
                                       <section title="Section B">
                                          <fields/>
                                       </section>
                                    </sections>
                                 </column>
                              </columns>
                           </basicfieldeditor>
                        </components>
                     </popup>
                  </action>
               </actions>
            </action>
         </rowactions>
         <massactions usefirstitemasdefault="true">
            <action type="massupdate"/>
            <action type="massdelete"/>
         </massactions>
         <views>
            <view type="standard"/>
         </views>
      </skootable>
   </components>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
</skuidpage>
Photo of Dylan Rodgers

Dylan Rodgers

  • 748 Points 500 badge 2x thumb
This works perfectly, thank you so much!

One last thing, if I wanted to show account fields on the event pop-up, would I have to create another account model that is the Id of the event I'm opening? That was the part that I thought was a little odd, considering the entire page is already specific Account Id.
Photo of Anna Wiersema

Anna Wiersema

  • 10,890 Points 10k badge 2x thumb
No, you shouldn't have to do that. You can just have the popup account field editor linked to the same Account Model you're using for the main page. Let me know if this is somehow not working.

You're welcome!