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
praveenkumarpraveenkumar 

Urgent : Recursively calling the same page

Hi All,

 

This is praveen, I am a salesforce user, i have written some part of visualforce code shown below,

 

 

 

<apex:page standardController="Account">
<apex:form >
<script>    
if("{!$Profile.Name}".substr(0,3)=="GFO")
 {      
     alert("New GFO accounts can only be created through lead conversion.  If you need assistance creating a new account, please contact SFDCacctrequests@progress.com");   
     window.location="https://tapp0.salesforce.com/001/o";
 }
 else
 {
     window.location="https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo";
 }
</script>
</apex:form>
</apex:page>

 

 

 

Now the issue what i am getting is ,this visualforce page is refreshing everytime when some users runs it other than GFO. If GFO users runs this it needs to show an alert with the above mentioned message...

 

I need an urgent solution for this issue...

if any one knows please send reply...

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

I suspect your problem will be resolved if you just append "Nooverride=1" in URL

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

All Answers

Ankit AroraAnkit Arora

Are you overriding the new button of account with this page?

 

Also can you please provide the complete URL used here :

 

window.location="https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_ur...";

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

Ankit AroraAnkit Arora

I suspect your problem will be resolved if you just append "Nooverride=1" in URL

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

This was selected as the best answer
praveenkumarpraveenkumar

Hi Ankit, Thanks for ur reply,

Yes ankit, I am overriding the new button in Accounts Standard object

 

Below is the complete URL:

 

https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo

 

 

I am still getting the same issue though i append "Nooverride=1".

Can u please giive another solution..

sherodsherod

Are't you just sending the user back to the same page they are on causing it all to re-evaluate again?

 

Try removing the else{ } statement.

 

 

praveenkumarpraveenkumar

Hi Sherod,

 

Thanks for giving reply.

 

If i remove the else { } block, any user can create the account, But my requirement is only GFO users should not create the account directly and other than GFO, we should allow them to create account by clicking the New button.

 

Thank you,

PRAVEEN KUMAR.

Ankit AroraAnkit Arora

According to your code you are redirecting to the record type page when it comes to the else part.

 

Please do a small change, when you are overriding the "New" button with visualforce page then check "Skip Record Type Selection Page" and try again.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

praveenkumarpraveenkumar

Thank you Ankit,

 

But if i check "Skip Record Type Selection Page" checkbox also i am getting the same problem,

 

Because we are overriding the page, it is navigating to the visualforce page and coming back to the accounts page, but it is not refreshing the same url.

 

This is happening recursively...

 

So i need the page to navigate only once.

praveenkumarpraveenkumar

Hi....

 

The problem is with the URL only, If i put some other url like "https://www.google.com" it is working fine..

 

But if i put the actual url like to which url it needs to navigate, it is not working fine....

 

Can u please modify the url querystring parameters...

 

The url is :

 

https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo

 

 

Its urgent pls help me....

brunol11brunol11

Hi!

 

I´m trying to understand the url you´ve posted. Seems like you´re redirecting the desired profile to a setup section of the Salesforce Platform.

But, according with what i just read from you issue, you want to redirect to a new account blank form, because the user profile allows this user to create a new account.

 

To review the link, go to Account Tab, click on the "NEW" button and while the form is still blank, copy the link from the navigator bar and paste into your code.

 

It would appear simple like this: https://tapp0.salesforce.com/001/e?retURL=%2F001%2Fo

 

This will provide a new blank form for the Account Object.

 

Hope it helps... or else I didn´t understand the issue and I´d like to know more about it.

In some cases, the triggers or workflows associated to you application, in addition to autosum fields, causes this recursive matter.

brunol11brunol11

There´s only one thing i didn´t get it.

 

If you´re dealing with profiles, why don´t you just uncheck the "Create" permission on Profiles Setup?

 

Even if you put it in a code as above, the GFO profile can type the url in the browser address bar and add an account. 

praveenkumarpraveenkumar

Hi Ankit,

 

Here is the trigger code, i need to write the test class for this trigger...

 

Can u pls help me in writing test class....

 

 

trigger Test on Opportunity (before update)

{   

    for(Opportunity a : Trigger.new)

    {       

        Opportunity beforeUpdate = System.Trigger.oldMap.get(a.Id);        

        if(beforeUpdate.StageName =='Lead'||beforeUpdate.StageName == 'Qualified Lead')

        {  

            If(a.StageName != 'Lead' && a.StageName != 'Qualified Lead'&& a.StageName!= 'No Opportunity')

            {        

                a.MQL_Promotion_Date__c = System.today();           

                system.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');

            }

            if(a.StageName == 'No Opportunity')

            {

                a.MQL_Rejection_Date__c = System.today(); 

                system.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');

            }

        }  

    }

praveenkumarpraveenkumar

Hi....

 

The problem is with the URL only, If i put some other url like "https://www.google.com" it is working fine..

 

But if i put the actual url like to which url it needs to navigate, it is not working fine....

 

Can u please modify the url querystring parameters...

 

The url is :

 

https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_ur...

 

Its urgent pls help me....

praveenkumarpraveenkumar

Hi Ankit,

 

Thanks for providing the  Query string parameter "Nooveride=1". It has helped in navigating to  the account page but before that it has to open the record type page then go to new account page. so can u please help me in improvising this code 

 

The url which i used is below:

 

https://tapp0.salesforce.com/setup/ui/recordtypeselect.jsp?ent=Account&retURL=%2F001%2Fo&save_new_url=%2F001%2Fe%3FretURL%3D%252F001%252Fo&nooverride

 

Thank you,