Field from Opportunities in Task Model

  • 1
  • Problem
  • Updated 2 years ago
  • Solved
Hi,

I need to have some opportunity fields in the task template to be used both on a display in a table or as filters. The link between the two models is wha.id task with id opportunity
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hi Andrea,

This is a Salesforce limitation for polymorphic relationships. Only id and Name fields are accessible.

There is a workaround though. You'd need:
- the whatid on the task model
- to ensure opps you need are in a Opp model
- the id on the Opp model
- UI only formula field with the model lookup function

Pat
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb
Thank You Vachon,

it works! How can I use UIonly formula as filter? 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Hmmm... You want to filter tasks based on Opp values?
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb
Yes, for example all tasks where the stage field is "
qualified" or something like this
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Well. Use a filter set based on a new Opp model and then create a model condition on Task Model using the Ids from it. The condition the condition to deactivate if now no rows.

If you already have filters setup on the task table, then it'll look a little odd, but this is the best option without going crazy in javascript.
Photo of Andrea

Andrea

  • 460 Points 250 badge 2x thumb
Thank you Pat!
Unfortunatly in this way I receive Apex heap size too large
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Set the new Opp model to not load on page load.