4

I want to code a button on a custom object to generate a task with some precompleted fields. I can do it like this:

/00T/e?what_id={!My_Object__c.Id}&tsk5="This is a Task"&tsk4={!TODAY()+21}&retURL=URLFOR($Action.My_Object__c.View,  My_Object__c.Id)])}

And it works; TODAY() is populated with "14/08/2014".

But I'm dependant on url structure. Eg suppose /00T/ changes to /00TA/.

It is preferable to use URLFOR().

Eg:

{!URLFOR($Action.Task.NewTask, null, [what_id=My_Object__c.Id, tsk5="This is a Task", tsk4=TODAY()+21, retURL=URLFOR($Action.My_Object__c.View,  My_Object__c.Id)])}

This will not work. In this case TODAY() is populated with "Thu Sep 04 00:00:00 GMT 2014" not "14/8/2014".

TODAY() returns data in a different format depending on whether its used in a hardcoded URL or within a URLFOR(). So is there a way to pass in a value to "tsk4" that is formatted correctly?

PS. Where is the documentation for generating Tasks through URLs? I can see people do it. I can see it works. I can't see any Salesforce documentation.

  • 1
    There is no documentation because it is not support by Salesforce. This is referred to as URL hacking, and you are right, many people do it, but Salesforce does not support it and any change on there end could break the hack. – Chris Duncombe Aug 14 '14 at 14:32
3

What you are trying to do is referred to as URL hacking, which is not supported by Salesforce. You are correct that your solution could break should Salesforce make any backend changes. I would propose that rather than trying to use URLFOR() to account for this, you look into using Publisher Actions. Publisher actions all but make URL hacking a thing of the past. It allows you to choose predefined values.

The best part about it is that this IS Salesforce supported so you don't have to worry about it breaking.

Here are some resources on using publisher actions instead of URL hacking

http://help.salesforce.com/help/pdfs/en/actions_impl_guide.pdf

http://salesforcewizard.wordpress.com/2014/01/08/great-url-hack-meet-the-chatter-publisher-action/

http://bobbuzzard.blogspot.com/2013/07/publisher-actions-not-just-creating.html

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009EToIAM

| improve this answer | |
  • 1
    Hmmmm....I wish people would comment when they down vote. Its the least you could do. Whats the point of down voting if you don't give a reason? – Chris Duncombe Aug 14 '14 at 18:15
  • It looks like the way to go in Salesforce and also avoids having to write a trigger to generate a Chatter entry for the Task. Those who dislike Chatter might object though. That's Salesforce's fault though, not yours. – powlo Aug 15 '14 at 9:15

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.