0

I have created a Skuid page that overlays Contact record pages. There is a "New" button which creates a new Taskrecord. on load of this new Task record, I wish for a TaskRelation record to be created and prepopulated with the associated Contact record.

To do this I am going to need the Id from the Task record and populate the TaskRelation record. Is it possible for me to get the Id from the new Task record before it has been saved? Or is the Task Id generated on save?

Use case: This is so the user knows the Contact has automatically been added associated with the Task

1
  • 1
    Why not write a trigger on Task on insert that will create TaskRelation for you automatically? Commented May 11, 2018 at 10:40

1 Answer 1

0

It's not possible to get the Id of an object before it has been inserted.
Only after the record is saved you can get it's Id.

I have not clear why you need the TaskRelation object to be created, but if you want to relate the Task record with the Contact record you can use the WhoId field of Task sObject to relate with Contact record.

Hope this solves what you are looking for.

6
  • This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
    – Dave Humm
    Commented May 11, 2018 at 12:45
  • Thanks for noticing, wrote on a rush :-) just updated the answer Commented May 11, 2018 at 14:02
  • 1
    Hi @Enrik. TaskRelatio allows you to assign same task to group of people, where as whoId allows you to assign a single entity. Commented May 11, 2018 at 14:02
  • @PranayJaiswal yeah I got it, but it is not clearly specified on the question that is needed to assign to a group of people Commented May 11, 2018 at 14:33
  • TaskRelation is only used for the same reason.. He's keen on using TaskRelation implies the architecture preference already made. Commented May 11, 2018 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .