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
SaaniaSaania 

Trouble directing a URL to a Tab

Hi,

I did an override of the New Button in Account Object, with my custom HTML SControl. The SControl simply checks unique Fice (our internal primary ID), and creates an account if the fice is unique.

When the fice is left empty, the user is simply taken to the new accounts page. I am using the following code to perform this action.

window.parent.location.href = "{!URLFOR($Action.Account.New, Account.Id, [retURL=URLFOR($Action.Account.New, Account.Id)], true)}"

The problem is, that if a valid fice and account name is entered, and an account created, I want the user to be redirected to either the edit page of the new account, or to the Account Tab. I tried the following options,

window.parent.location.href = "{!URLFOR($Action.Account.Tab, Account.Id)}"

and window.parent.location.href = "{!URLFOR($Action.Account.Edit, Account.Id)}"

but the page is not redirected to either the Tab or the edit page. It remains in the html page of scontrol.

Thanks,

Saania

michaelforcemichaelforce

To make sure that the window will be redirected i typically use:

top.window.location="myURLString";

This way it doesn't matter if it's called from an s-control or from the main app (custom button, link, etc.).  It might not fix it... but worth a shot.

rockchick322004rockchick322004
I think that the issue is that you don't yet have the Account ID when the URLFOR() function is evaluated.  All of the functions are evaluated on the server, before your sControl code runs.  So, in this case, the Account ID that you want for the Account Tab and the Account Edit urls is not known yet, because it is created by your sControl.
SaaniaSaania

Thanks for the replies, the AccountId not being there does make sense. but shouldnt redirecting to an Account Tab be oblivious of the AccountId? Is there a work around to accomplish this?

 

Thanks,

 

Saania