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
SurekaSureka 

Issue in Case sensitive Ids in URL

Hi,

 

I am facing a strange issue in Building a URL:

 

I have the following URL - where I have two Ids - 00NA0000009yWHr & 00NA0000009yWHR. These are different fields. 

 

But when the fields are rendered in UI, it is just changed to one id . Please help me in resolving the issue.

 

/a6i/e?00NA0000009yWHr=Created+in+error&00NA0000009yWHR=RKI+Account&retURL=%2F001J000000ZaCxGIAV
/a6i/e?00NA0000009yWHR=RKI+Account&retURL=%2F001J000000ZaCxGIAV
AdrianCCAdrianCC

Hello,

 

Where are you using these ids? How is the url created? A pagereference in a controller? Can you please show a little more code?

Also, have you tried using the 18 char version of the ids? I know, it shouldn't matter since the 15 one is case sensitive... http://www.salesforce.com/us/developer/docs/api/Content/field_types.htm#i1435616

 

Ty,

Adrian

SurekaSureka

Hi,

 

This is my code:

 

String redirctURL;

Pagereference p;

redirctURL = '/'+ objResult.getKeyPrefix()+'/e?'+'00NA0000009yWHr='+account.Industry__c
+'&00NA0000009yWHR='+account.NewSite
+'&retURL=%2F'+account.Id;    

p = new pagereference(redirectURL);

return p;

 

Above code is rendered as '/021/e?00NA0000009yWHr=NewIndustry&retURL=%2F00100000012A21;    

ie. Other Id value is not coming.

 


Please help me in resolving the issue

Thanks

AdrianCCAdrianCC

You're right. I played with your code in the Dev Console and it gives indeed that weird result... I guess the parameters set for a pageReference is not case sensitive. 

 

Anyway, try smth like this in your code and tell me if it works:

String redirectURL = '/e?'+'00NA0000009yWHr='+'industryid' + '&00NA0000009yWHR='+'siteId' +'&retURL=%2F'+'accountId';    

String encoded = EncodingUtil.urlEncode(redirectURL, 'UTF-8');
Pagereference p = new pagereference(encoded);
System.debug('URL has this value: ' + p.getUrl());

 Thanks,

Adrian

 

SurekaSureka

Hey,

 

Thanks for the suggestion. I got the following error after using Encoding.

 

java.lang.IllegalArgumentException: Illegal view ID %2Fa6i%2Fe%3F00NA0000009yWHR%3DRKI+Account%2600NA0000009yWHr%3DCreated+in+error%26retURL%3D001J000000ZaCxGIAV. The ID must begin with /

 

Thanks

AdrianCCAdrianCC

Let's try to tackle this from another angle.

Instead of forming the url in the controller with a PageReference, which as it seems it's not working, let's try to add the url in the page. Add an onclick event to your button or link that references some js redirect code

onclick="window.open('/{!KeyPrefix}/e?00NA0000009yWHr={!account.Industry__c}&00NA0000009yWHR={!account.NewSite}&retURL=%2F{!account.Id}')"

 You'll need to create a getter for the keyprefix and the account. Also comment out or remove the existing PageReference. Change the methods type to void.

 

Ty,

Adrian

 

asish1989asish1989

HI

I was looking at your code ,You have written account.NewSite . What is NewSite here?

It seems from syntax It is a standard field of Account, but there is no such field in account.

 

If this post answers your question please mark it asl solved and give kudos for this post If It helps you

 

Thanks