Task object, reference the account of a contact on a task

  • 1
  • Question
  • Updated 11 months ago
  • Answered
I am trying to pull in all tasks that are related to an account, however, a good number of tasks are associated to a contact related to the account and don't have an account listed with the task. I saw some other posts about this but I was wondering if there is anyway to drill into the WhoId field on the task and pull the account that the contact is associated with? Or if you have any other work-arounds, I would love to know more! I tried using the child relationships object, but our reps would like the ability to create a new record inline and have these tasks in a table view
Photo of Megan Minahan

Megan Minahan

  • 726 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Gregg Baxter

Gregg Baxter, Official Rep

  • 3,080 Points 3k badge 2x thumb
Hi Megan

When you create a task you have the opportunity to select Contact or Lead = WhoId and Related to = WhatId

The Contact record has an AccountId field and if the contact is linked to an Account then this will be populated with the AccountId.

You can then filter on the Task object by AccountId which will display all task for the Account and Contacts linked to the AccountId.

I have created a quick page with the filters you can look at:

Create a new page and paste the below XML.  

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">   <models>
      <model id="AccMod1" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Account">
         <fields>
            <field id="Name"/>
         </fields>
         <conditions>
            <condition type="param" value="id" field="Id" operator="=" state="" enclosevalueinquotes="true" novaluebehavior=""/>
         </conditions>
         <actions/>
      </model>
      <model id="ContModel" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Contact">
         <fields>
            <field id="AccountId"/>
            <field id="Account.Name"/>
            <field id="Id"/>
            <field id="FirstName"/>
            <field id="LastName"/>
         </fields>
         <conditions>
            <condition type="param" value="id" field="AccountId" operator="=" mergefield="Id" novaluebehavior="deactivate" enclosevalueinquotes="true"/>
         </conditions>
         <actions/>
      </model>
      <model id="TAskMod" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Task">
         <fields>
            <field id="AccountId"/>
            <field id="Account.Name"/>
            <field id="WhoId"/>
            <field id="Who.Name"/>
            <field id="WhatId"/>
            <field id="What.Name"/>
            <field id="Id"/>
            <field id="OwnerId"/>
            <field id="Owner.Name"/>
            <field id="IsClosed"/>
            <field id="Description"/>
         </fields>
         <conditions/>
         <actions/>
      </model>
   </models>
   <components>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="AccMod1" buttonposition="" mode="read" uniqueid="sk-24IHG0-108">
         <fields>
            <field id="Name"/>
         </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>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="ContModel" buttonposition="" mode="read" uniqueid="sk-24IHbq-120">
         <fields>
            <field id="AccountId"/>
            <field id="Id"/>
            <field id="FirstName"/>
            <field id="LastName"/>
         </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>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="TAskMod" buttonposition="" mode="read" uniqueid="sk-24II5G-132">
         <fields>
            <field id="AccountId"/>
            <field id="WhoId" valuehalign="" type=""/>
            <field id="WhatId"/>
            <field id="Id"/>
            <field id="OwnerId"/>
            <field id="IsClosed"/>
            <field id="Description"/>
         </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/>
      <javascript/>
      <css/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Yup.  Greg is right! 
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Another idea would be to create a model on contacts and put a condition on it to only allow contacts associated with the account(s) you want to display associated tasks. Then on your task model, you can create a condition that only allows tasks With WhoId's that are in your contact model. You would still need the condition to display tasks linked directly to the account as wel, so set your model condition logic to "1 or 2". Then it should display all tasks associated with the account and tasks associated with contacts that are associated with the account.
Photo of Megan Minahan

Megan Minahan

  • 726 Points 500 badge 2x thumb
Thank you! I tried both Gregg and Raymond's method and I was more along the track Raymond was going, just didn't think to reference the contact id when I created my filters.
Photo of dominica

dominica

  • 60 Points
rrrr