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
    Why not write a trigger on Task on insert that will create TaskRelation for you automatically? – Pranay Jaiswal May 11 '18 at 10:40

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.

  • 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 May 11 '18 at 12:45
  • Thanks for noticing, wrote on a rush :-) just updated the answer – Enrik Hysko May 11 '18 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. – Pranay Jaiswal May 11 '18 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 – Enrik Hysko May 11 '18 at 14:33
  • TaskRelation is only used for the same reason.. He's keen on using TaskRelation implies the architecture preference already made. – Pranay Jaiswal May 11 '18 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.