You need to sign in to do that
Don't have an account?
finalist
I'm sure there's a simple way to set window.location to something real, but I haven't figured out what it is.
Message Edited by finalist on 08-20-2008 03:03 PM
Returning gracefully to original page when query returns no data
I have an S-Control that is triggered from a button, queries the database for related objects,
and winds up on an edit page for a new custom object in either the Console or a tab depending on where we started.
If the query is successful, I call a function, determine by window.parent.location.href whether we're in the Console or not and do what I need to do.
If the query returns no data, I can display a message to the user (very advanced, I know), but I can't figure out how to get back to where I started.
I tried using window.parent.location.href = window.parent.location.href, or using a variable for retURL = "{!$Request.retURL}",
but both of these result in an endless loop of message displays and empty pages.
The button's behavior is 'Display in existing window without sidebar or header'
Here is my code for determining location, which works fine when there's data:
Code:
if(window.parent.location.href=="https://na5.salesforce.com/ui/desktop/DesktopPage") { finishedLocation = '/a0H/e—CF00N70000002Jgyz=' + ...
+ &CF00N70000002JgwU={!Customer_Subscription__c.Name}
&CF00N70000002JgwU_lkid={!Customer_Subscription__c.Id}
&retURL=%2F{!Customer_Subscription__c.Id}&isdtp=mn' } else { finishedLocation = '/a0H/e–CF00N70000002Jgyz=' + ...
+ &CF00N70000002JgwU={!Customer_Subscription__c.Name}
&CF00N70000002JgwU_lkid={!Customer_Subscription__c.Id}
&retURL=%2F{!Customer_Subscription__c.Id}&}; }
And here's the code that verifies whether I have any actual results:
Code:
if (results.size > 0) { var ri = new sforce.QueryResultIterator(results); while (ri.hasNext()) { // parseServiceBlocks calls the previous ^ function parseServiceBlock(ri.next()); }; } else { // no records were returned, i.e. there are no active Service blocks alert("There are no active Subscription & Service blocks for this Subscription"); // At this point, we want to return the user to the original page }
I'm sure there's a simple way to set window.location to something real, but I haven't figured out what it is.
Thanks!
Message Edited by finalist on 08-20-2008 03:03 PM
Thanks for hanging in with me!