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
Manu ErwinManu Erwin 

Error when overriding Activity Log a Call or Send an Email

I need to pre-default the Related To field in tasks and events to the Contact's Account Id.

It's working when I've overridden 'New Task' and 'New Event', however when I try much the same thing with the 'Log a call' and 'Send an Email' functions my s-control has an error.

Successful s-control for overriding 'New Task' making use of URLFOR functionality.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js"></script>
<script type="text/javascript" >
function redirectToRecord() {
var newURL = "{!URLFOR($Action.Task.NewTask, null, [who_id=Contact.Id, what_id=Account.Id, retURL=URLFOR($Action.Contact.View, Contact.Id)], true)}";
parent.frames.location.replace(newURL);
}
</script>
</head>
<body onload="redirectToRecord();">
</body>
</html>

Unsuccessful s-control for overriding 'Log a Call' making use of URLFOR functionality.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js"></script>
<script type="text/javascript" >
function redirectToRecord() {
var newURL = "{!URLFOR($Action.Activity.LogCall, null, [who_id=Contact.Id, what_id=Account.Id, retURL=URLFOR($Action.Contact.View, Contact.Id)], true)}";
parent.frames.location.replace(newURL);
}
</script>
</head>
<body onload="redirectToRecord();">
</body>
</html>

This causes the s-control to run twice? and the browser URL ends up with an error: https://cs2.salesforce.com/servlet/servlet.Integration?lid=01NR00000004SFO&ic=1#Error! that seems to thankfully prevent it from looping infinitely.

Any suggestions about what I should try?

Note: the Send an Email s-control is almost the same as above but with the different action of course.


Message Edited by manu on 08-13-2008 04:05 PM

Message Edited by manu on 08-13-2008 04:05 PM
Manu ErwinManu Erwin
Update:
Have discovered that if I remove the retURL piece within inputs of URLFOR the page does not error i.e.,

New Code:
var newURL = "{!URLFOR($Action.Activity.LogCall, null, [who_id=Contact.Id, what_id=Account.Id], true)}"; 

however the who_id and what_id fields are not populated.

Am wondering if it has something to do with the format of the URL string as this does not populate the fields:

Code:
https://cs2.salesforce.com/00T/e?followup=1&retURL=%2F00T%2Fe%3Ftitle%3DCall%26who_id%3D003R0000002Zo9Z%26followup%3D1%26tsk5%3DCall%26retURL%3D%252F003R0000002Zo9Z&tsk5=Call&nooverride=1


whereas this does:

Code:
https://cs2.salesforce.com/00T/e?followup=1&retURL=%2F00T%2Fe%3Ftitle=Call&who_id=003R0000002Zo9Z&followup=1&tsk5=Call&retURL=%252F003R0000002Zo9Z&tsk5=Call&nooverride=1
 

Do I need to somehow change the URL characters back to '=' and '&'  before redirecting the page?? 

Also, the what_id is included in the inputs for URLFOR but does not show here, whereas it works for 'New Task'?



Message Edited by manu on 08-14-2008 08:56 AM
kevinedelmannkevinedelmann
not sure why it is not working but you could also try tsk3 = contact.ID
vtkstefvtkstef
While on the subject (apologizing for not being able to shed any further light into the matter), is it possible to pass a default value for the activity subject field too?
I have tried passing "subject=", "subject_id=", "Subject=" as a URL parameter, but it did not work.

Ciao
Stefano


Manu ErwinManu Erwin
Thanks kevinedelmann for the response. Am hoping to avoid 'hardcoding' the URL string with page field codes in case the behind the scenes fields change at some point in the future but if not will be going along the lines of your suggestion.......

thanks :)
manu