
I am trying to create a custom Event button called "Log a Meeting" that displays on the Activity History related lists of the Lead, Account, Contact, and Opportunity records and functions the same as the "New Event" button - opens a new event for that record (similar to the "Log a Call," but for events instead of tasks).
I am having trouble determining the code for this button and would love some help. I am not a Developer, so am learning as I go. Below is what I have so far, but I am having trouble identifying a command to actually open the Event url - or do I need to tell it to open a New Event instead of listing the URL? Will the below even get me anywhere (currently it does nothing)?
If I could just mirror the NewEvent script I'd be good, but I cannot find it anywhere.
if ('{!Lead.Id}'!='') {
https://na4.salesforce.com/00U/e?who_id={!Lead.Id}&retURL=%2F{!Lead.Id};
}
else if ('{!Opportunity.Id}'!='') {
https://na4.salesforce.com/00U/e?what_id={!Opportunity.Id}&retURL=%2F{!Opportunity.Id};
}
else if ('{!Contact.Id}'!=''){
https://na4.salesforce.com/00U/e?who_id={!Contact.Id}&what_id={!Account.Id}&retURL=%2F{!Contact.Id};
}
else {https://na4.salesforce.com/00U/e?what_id={!Account.Id}&retURL=%2F{!Account.Id}
}
I already posted a similar question, which got me this far, and I'm still struggling.
Thank you!!
Celia
8 respuestas
Well you're close now, but what you need is to set the window.location property. As it stands you're just outputting a URL but you're not telling JS what to do with it.
Also, while you're at it, you should use relative URLs -- no need to put the full "https://na4.salesforce.com" in there, and that could break if you ever got moved to a different server.
window.location = "/00U/e?who_id={!Lead.Id}&retURL=%2F{!Lead.Id};";
Be sure not to forget the quotes, or the semicolons at the ends of each URL.