0

I'm trying to send a value from one page to another, I've tried adding it to my URL.

{!my_val} //Value is a simple string

<apex:outputLink value="/apex/NewPage?id={the_account.id}_myValue{!my_val}">
    <div class="link_class">
        <strong>Link</strong>
    </div>
</apex:outputLink>

But I have an Id at the end of my url and when I add my value, I get the following error:

Id value is not valid for the standard controller 

So I'm assuming the value is breaking the Id.

If I add it before my Id, Salesforce says it can't find my page, so it seems to be breaking my Url.

{!my_val}    

<apex:outputLink value="/apex/NewPage_myValue{!my_val}?id={the_account.id}">
    <div class="link_class">
        <strong>Link</strong>
    </div>
</apex:outputLink> 

Is there any way to pass my value through in my url?

UPDATE

Adding an ampersand seems to do the trick... Page loads and my value is appended to my Url with no errors.

<apex:outputLink value="/apex/NewPage?id={the_account.id}&myValue{!my_val}">
    <div class="link_class">
        <strong>Link</strong>
    </div>
</apex:outputLink>

Would anyone be able to tell me if this an acceptable solution?

Or are ampersands supposed to be avoided in Urls?

1

@Daft, I think you resolved your own question. When passing more than one varialbes in a url, you need to seperate them using ampersand (&).

single variable: http://myapp.test.com?var1=1

2 variables: http://myapp.test.com?var1=1&var2=2

Note that the url string should be encoded for the browser to parse it correctly.

1

Looks like you are missing a double quote at the end of your url?

apex:outputLink value="/apex/NewPage?id={the_account.id}"

  • Cheers, but that was just a copy and paste error while writing my question – Daft Feb 17 '15 at 10:05
0

I think you forget to put 'myValue='

VF Page

 <apex:outputLink value="/apex/NewPage?id={the_account.id}&myValue={!my_val}">`enter preformatted text here`
        <div class="link_class">
            <strong>Link</strong>
        </div>
    </apex:outputLink>

Apex Code :

System.currentPageReference().getParameters().get('myValue');

I think this might be useful for you if im wrong then please correct me.

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.