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
RajeevlsHydRajeevlsHyd 

Parameters not getting passes properly in URL

I have written a method in controller class to pass two ids in the URL to the next vf page ... but it is not going properly in the URL..

 

public pagereference upload()
{
Id so ;
Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');
for(SOWrap sw :wrapper)
{
so = sw.SOID;
}
return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId =' + oppId);

}

 

 

The URL it is passing is :

 

https://cs16.salesforce.com/apex/DocumentUploader?+OppId+=006f0000003aqzUAAQ&Id=a39f00000004IKtAAM

 

I am not able to use OppId in the new page, page not loading .. any help here

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
remove the extra space after the oppId parameter
return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId=' + oppId);

All Answers

digamber.prasaddigamber.prasad

Hi,

 

I can see the problem is in the URL you have pasted i.e. "https://cs16.salesforce.com/apex/DocumentUploader?+OppId+=006f0000003aqzUAAQ&Id=a39f00000004IKtAAM". It has additional '+' before and after 'OppId'. The correct URL should be https://cs16.salesforce.com/apex/DocumentUploader?OppId=006f0000003aqzUAAQ&Id=a39f00000004IKtAAM.

 

However, I did a dry run to replicate the same on my dev org and working absolutely fine. Could you please elaborate bit more on what you are trying to do.

 

Happy to help you!

 

Regards,

Digamber Prasad

RajeevlsHydRajeevlsHyd

I am trying to pass two parameters to a new VF page , so I used the following line in the method in the controller :

 

public pagereference upload()
{
Id so ;
Id oppId = ApexPages.CurrentPage().getParameters().get('OpId');
for(SOWrap sw :wrapper)
{
so = sw.SOID;
}
return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId =' + oppId);
}

 

This page URL has a parameter OpId -  Opportunity ID  - which I want to pass on to the next page .. but when I am clicking on the button which calls this method... it is giving this defect URL :

 

https://cs16.salesforce.com/apex/DocumentUploader?+OppId+=006f0000003aqzUAAQ&Id=a39f00000004IKtAAM

Bhawani SharmaBhawani Sharma
RajeevlsHydRajeevlsHyd

This is working ...but when I refresh it or again load this page , it is not working.

How can i get the URL corrected?

Bhawani SharmaBhawani Sharma
What is the URL in address bar when you are hitting refresh?
georggeorg

Seems like a glitch in salesforce:-(

 

I just tried and got the same, but when i tried after removing all the spaces inside the strings it is working perfectly. Try removing all the unnecessary spaces in the string and let me know if the issue is still there.

 

Thanks,

George

Visit my blog here

RajeevlsHydRajeevlsHyd

The url is the this :

 

https://cs16.salesforce.com/apex/DocumentUploader?Id=a39f00000004IKtAAM&OppId+=006f0000003aqzUAAQ 

 

It has an opportunity Id.. but I cannot use this because when I query with this id , its giving 

 


System.QueryException: List has no rows for assignment to SObject

Error is in expression '{!ReturnTo}' in component <apex:commandButton> in page documentuploader

 

 

Class.AttachmentUploaderController.ReturnTo: line 38, column 1

 

 

The return to method on this page :

 

public PageReference ReturnTo()

{
Id oppId = ApexPages.CurrentPage().getParameters().get('OppId');

opp = (Opportunity)[select Id, Name from Opportunity where Id =: oppId];
pageReference pg4 = new pageReference('/apex/DSFinalPage?OpId=' +opp.Id);
pg4.setRedirect(true);
return pg4;
}

 

Bhawani SharmaBhawani Sharma
How this +(plus) character came in your URL?

It should be exactly like this:
https://cs16.salesforce.com/apex/DocumentUploader?Id=a39f00000004IKtAAM&OppId=006f0000003aqzUAAQ
RajeevlsHydRajeevlsHyd

i am using this line of code to recirect :

 

 return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId =' + oppId); 

 

the url which is passing is :

 

https://cs16.salesforce.com/apex/DocumentUploader?Id=a39f00000004ILRAA2&OppId+=006f0000003aqzUAAQ

 

here I want to use OppId to querry but cannot access because when I query with OppId , it giving error :

 

System.QueryException: List has no rows for assignment to SObject

 

Whats the correction i can make here?

Bhawani SharmaBhawani Sharma
remove the extra space after the oppId parameter
return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId=' + oppId);
This was selected as the best answer
RajeevlsHydRajeevlsHyd

I am not getting how this extra + sign is appended with the OppId in the URL, because the line of code says :

return new pagereference('/apex/DocumentUploader?Id=' +so+ '&OppId =' + oppId);

RajeevlsHydRajeevlsHyd

This works.. thanks for the help