function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
megmooPDXmegmooPDX 

URL hack for Related To not working

I have a custom list button that I want to open up a task window with some fields pre-populated. I can pre-populate all the fields I need to except the Related To field, however, I can set the Related To object to my custom object. I just can't get the name to populate in the Related To field

Here's my URL hack
/00T/e?tsk3={!ACA_Member__c.Name}&tsk3_mlktp=a07&followup=1&tsk5=Received DNE member call&00Ni000000Ci0El=DNE call&tsk6=Logged via quick DNE button&retURL={!ACA_Member__c.Id}

Here's a screen shot. The URL successfully sets the object for "Related To" to ACA Member (the red circle), but I can't get the member's name to display in the related text field (the green arrow field). 
User-added image

I have tried this string, too:
/00T/e?what_id={!ACA_Member__c.Id}&followup=1&tsk5=Received DNE member call&00Ni000000Ci0El=DNE call&tsk6=Logged via quick DNE button&retURL={!ACA_Member__c.Id}


Can anyone help me out with this? I feel like I'm going in circles because everything I've found online says that that the what_id should do what I need it to. Thanks in advance!




Best Answer chosen by megmooPDX
megmooPDXmegmooPDX
I have found that using Publisher Actions is a better solution than URL hacking or a javaScript button. Publisher Actions have their limits (see my Idea (https://success.salesforce.com/ideaView?id=08730000000l2BJAAY) on the Idea Exchange for an enhancment), but so far, they're much better.

All Answers

ShaTShaT
Hi ,

You need to pass the value in input box . I have highlited the area where you get the id and where you need to insert in URL.

Eg -
User-added image

Thanks
Shailu
megmooPDXmegmooPDX
I was trying to set tsk3 via tsk3={!ACA_Member__c.Name}.

I think I've now realized what the problem is, but I still don't know how to fix it. I have this button with the same information being passed in two locations: in the Activity Related list of the parent (custom) object of ACA_Member__c. In this instance, it works just fine. 

I also have this button on the Search page for the parent object. See the screen shot below

User-added image

The problem is that when I select a member from this list (in the screen shot above, this is Aleksandra Gray), then click the "DNE received" button (which I want to open a new task window for Aleksandar Gray) it doesn't know which member I'm creating the task for. I need some way of
1. finding which member on the screen is selected
2. ensuring that if >1 member is selected, it throws an error message like "Only one member can be selected"
3. ensuring that if no member is selected, it throws an error message like "A member must be slected."

Starting with #1, any ideas if I can get the ID of the currently selected member in the search list?
ShaTShaT
Hi,

Change the behavior of the button from URL to JavaScript and paste the below code.

var ids = {!GETRECORDIDS($ObjectType.YOUROBJECTNAME)};
if (ids.length != 1)
{ alert("Please Select One record");
}
else
{
window.open("/00T/e?who_id="+ids,'_self');// YOUR URL
}

Hope this works for you..

Thanks
Shailu
megmooPDXmegmooPDX
Hi, Shailu -

You've gotten me closer!

An FYI before I detail the remaining two issues: who_id is irrelevant because my task is not associated with a contact. The link is through the Related To field which sets to my custom object (ACA_Member__c) and then the associated member record. Also, for an unknown reason, setting the what_id doesn't seem to work, so I am setting the tsk3. And finally, passing the ID to the what_id/tsk3 field doesn't work - it expects the Name of the member to be passed. 

So my two remaining issues:
  1. As noted above, passing the ID into the Related To field gives me an error (and this is definitely a valid ID). The javascript is grabbing the correct ID from my object, however, when I pass it to the task object via the URL, my task wants the name of that member, not the ID (see screen grab below). Is there a way for me to get the Name of the record? I'm completely new to Apex/Javascript/VF, so this may sound absurd, but I was wondering if I can create an apex class that takes the ID and then does a lookup to return the name. No idea what that code would look like, but wondering if that concept would work. Or is there an easier way if it is possible? User-added image
  2. My second problem is that, even when I correctly associate the task - via the Related To field - to an ACA_Member record, it does not save/associate correctly. I am using the same method in another part of the application (using the same URL) and that saves just fine. Any idea why it's not saving and/or associating properly?

Here's my code, edited from yours

var ids = {!GETRECORDIDS($ObjectType.ACA_Member__c)};
if (ids.length != 1)
{ alert("Please Select One record");
}
else
{
window.open("/00T/e?&tsk3_mlktp=a07&00Ni000000Ci0El=DNE call&tsk5=Received DNE member call&tsk6=Logged via quick DNE button&RecordType=012i00000015aK8&tsk3="+ids,'_self');// YOUR URL
}
megmooPDXmegmooPDX
I have found that using Publisher Actions is a better solution than URL hacking or a javaScript button. Publisher Actions have their limits (see my Idea (https://success.salesforce.com/ideaView?id=08730000000l2BJAAY) on the Idea Exchange for an enhancment), but so far, they're much better.
This was selected as the best answer