You need to sign in to do that
Don't have an account?
finalist
Refreshing Lead Detail from Console or directly, after update via S-Control
Hi everyone,
I've posted about similar issues before, and searched the forums, and I apologize if there's a solution that I've missed in here somewhere; here's the problem:
From a Lead (or anywhere, really, but let's keep it simple), I have custom buttons triggering S-Controls that
The Lead detail is not refreshed, however, so there is no indication that anything really happened. I've tried using setTimeout() to give the page time to refresh, to no avail.
I've also tried to determine whether the user was in the Console at the time they clicked the button or whether they were on the Leads tab, by checking whether window.parent.location.href == "https://(server).salesforce.com/ui/desktop/DesktopPage", but this isn't working either.
I am using dojo, and opener.location.reload is returning them to the right place, but not refreshing the page (as I mentioned.)
Here are the two relevant bits of code; the first, an attempt to identify whether it's the console or not:
and the second, to refresh the lead detail, irrespective of the location:
Right now, setTimeout() is only serving the purpose of displaying a page with the message "Logging voicemail ..." or something
to that effect, leaving enough time for the message to be read and then returning to the lead detail.
Thanks for your help! :)
I've posted about similar issues before, and searched the forums, and I apologize if there's a solution that I've missed in here somewhere; here's the problem:
From a Lead (or anywhere, really, but let's keep it simple), I have custom buttons triggering S-Controls that
- update fields on the lead, and
- create new custom objects with lookups to the lead
The Lead detail is not refreshed, however, so there is no indication that anything really happened. I've tried using setTimeout() to give the page time to refresh, to no avail.
I've also tried to determine whether the user was in the Console at the time they clicked the button or whether they were on the Leads tab, by checking whether window.parent.location.href == "https://(server).salesforce.com/ui/desktop/DesktopPage", but this isn't working either.
I am using dojo, and opener.location.reload is returning them to the right place, but not refreshing the page (as I mentioned.)
Here are the two relevant bits of code; the first, an attempt to identify whether it's the console or not:
Code:
if (window.parent.location.href=="https://na3.salesforce.com/ui/desktop/DesktopPage") { alert("Opened from console ..."); finishedLocation = '/{!Lead.Id}—isdtp=mn'; } else { alert("Opened from leads tab ..."); finishedLocation = '/{!Lead.Id}'; } // followed by window.location = finishedLocation
and the second, to refresh the lead detail, irrespective of the location:
Code:
/* I am not using both this code AND window.location = finishedLocation; since finishedLocation wasn't doing its job, I've just been using this:
*/ // do the processing that needs to be done, then setTimeout("updateComplete()", 750); } function updateComplete() { opener.location.reload; //opener.focus(); // window.parent.location.reload; // parent.parent.frames.location.replace("/{!Lead.Id}"); }
Right now, setTimeout() is only serving the purpose of displaying a page with the message "Logging voicemail ..." or something
to that effect, leaving enough time for the message to be read and then returning to the lead detail.
Thanks for your help! :)
Remember that the console is framed, and the opener may in fact be a frame and not a whole window. If you want to check whether the user is in the console, look for the isdtp=mn parameter in the frame's URL.
As to your question re: Firebug, no, I hadn't specifically looked at opener to see if there was a value. Is there a better/more precise way of 'phrasing' the 1st bit of code to determine the URL, i.e. whether it's called from the Console?
C
Any (more :) ) help would be appreciated.
I might have better luck? (the errant - was supposed to be a ?; something weird with the paste-job there)
I do have an O'Reilly guide to JavaScript, so hopefully it's in there ...
http://www.w3schools.com/jsref/jsref_indexOf.asp
Okay - it is working now. It does not have the (necessary) elegance suggested above for using index.of, so it will need to be modified if the server is migrated, but otherwise this does the job.
To refresh your memory, this is called from a button on the Contact record, and creates a new Lead from the Contact. Based on whether it is called from within the Console or not, the new Lead is loaded either full-screen or in the Console window.
Thanks for your help!
Message Edited by finalist on 07-30-2008 02:02 PM
Message Edited by finalist on 07-30-2008 02:03 PM
I've written a javascript function that will check if you are in the console that works between servers (using indexOf, as suggested earlier)
Then before you call your redirection code you check if the user is in the console and add the appropriate 'isdtp=mn' to the query string.
Example:
Note: redirect() is a function I created for handling re-directs, obviously you'd use whatever your redirect code is there. I use:
For Salesforce Classic you could still use `window.location.href`
This is the documentation url for refrence
https://help.salesforce.com/articleView?id=sf.lex_prepare_vf_window.htm&type=5 (http://https://help.salesforce.com/articleView?id=sf.lex_prepare_vf_window.htm&type=5)