1

I'm having an issue with a PageReference redirect that is unexpected for me and out of the ordinary compared to what I'm used to.

I have a custom detail button which directs the user to a custom VF page and controller where logic is completing some checks/updates and then redirecting the user to the standard managed package VF page.

However at that point the name of the managed package vf page is duplicating which is causing me to get the following error:

The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

My code is contained below - I've been able to do this with other managed packages before like FinancialForce but for some reason Steelbrick is being trickier:

String redirectUrl = Page.sbaa__Approve.getURL();
    system.debug('@@@urlstring' + redirectUrl);

    if (approve == 'true'){
        pageReference redirect = new pageReference('/'+redirectUrl+'/?scontrolCaching=1&id='+approvalId);
        //redirect.setRedirect(true);
        return redirect;
    }

Error message displayed and here is the url:

/apex/sbaa__approve/approve/?scontrolCaching=1&id=aD8C0000000CacjKAC

enter image description here Has anyone else ran into and solved this error before?

  • Can you edit your question to include a complete url which gives you this message? – battery.cord Jun 7 '17 at 20:29
1

Remove the first dash after redirectUrl. Your browser think it's looking for a page named ?scontrolCaching, instead of a page named approve‌​ with some url parameters. Your full url should look like this:

https://advisory--q2cdev3--sbaa.cs12.visual.force.com/apex/s‌​baa__approve/approve‌​?scontrolCaching=1&i‌​d=aD8C0000000CacjKAC
  • Now I just feel stupid - can't believe I overlooked that. Thank you so much for your help! – cg13 Jun 7 '17 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.