1

Using SOQL I can see that there is a field called WhatId for the Event object. But if I want to use this field in a URL hack, I get the error 'Field Event.WhatId does not exist'.

I googled a but, so I also tried Event.What.Id: same result. Also WhoId and Who.Id: same result.

A field like ActivityDate is accessible via {!Event.ActivityDate}, why can't I access WhatId or WhoId? How to do it?

To be more precise: it is not my intention to create an Event via a URL hack, but to use the Event.WhatId field in a URL.

1

URL hacks are based on the name of the form field in the page that is being accessed.

So for example, looking at the "Task Edit" page (use your browser's "Inspect Element"), the text displayed for "Assigned To" uses the field name tsk1 and the underlying Id value is in a hidden field called tsk1_lkid. So append &tsk1=John&tsk1_lkid=0055600000155pM to the URL to pre-populate those.

Salesforce do not consider these names and the mechanism to be part of a supported API so they could change. But that is likely to break many customisations because as there is no alternative "API" way of accomplishing this people choose to take the hack approach.

(For the WhatId, I think the field names are tsk2 and tsk2_lkid.)

| improve this answer | |
  • Probably it also needs to pass additional url Parameter for selecting the object. – Raul May 30 '18 at 8:42
  • @Raul AFAIK the two parameters cover it: one is the name of the object and the other is the Id of the object (lkid is short for lookup Id). – Keith C May 30 '18 at 8:44
  • From what I remember, we also have to select which object we want to select the record from in what and who id fields. – Raul May 30 '18 at 8:48
  • Thank, but it does not help me. I added some, hopefully, clarifying text to my question. – Sander de Jong May 30 '18 at 8:56
  • 1
    @SanderdeJong Think might be worth clarifying your question a bit more: sounds like you want to run a query in Apex and add the Id value returned to a URL? – Keith C May 30 '18 at 8:59
1

What I wanted to do: create a custom button that starts a Task edit window using the contents of an existing Event. One of the fields that I want to use is the Account of the Event. This is the 'Related to Id', technically known as WhatId. But although Event.WhatId is valid SOQL, for some reason you cannot use it in the formula editor for the URL of a custom button.

So my workaround is to create two new Event fields, being text formulas:

  • AccountId__c = Account.Id
  • AccountName__c = Account.Name

This is possible, even though the formula editor does not offer you Account as an Event attribute. Apparently it is a hidden attribute.

Now that I have these fields (I need both of them, to fill a lookup field), I can create the URL hack:

/00T/e?tsk4={!Event.ActivityDate}&tsk3_mlktp=001&tsk3={!Event.AccountName__c}&tsk3_lkid={!Event.AccountId__c}
| improve this answer | |

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.