+ Start a Discussion

Issue passing currency value to URL hack


I am at a loss, I have tried everyhting I know to try and get a Custom button in the Contract to pass a currency value in the URL but I keep getting "System.TypeException: Invalid decimal: " error. I first tried passing in the CurrencyIsoCode along with the currency field in the URL, but I still get the error:


The issue is that it is passing the currency and also a comma value, for example: value in field 12.34, shown in the contract page as 12,34 due to user locale settings is passed as  USD 12,34 instead of the decimal value.

Then I tried to add some code in the OppOverrideEdit controller to try and remove both the currency and the comma replacing it with a period as so:
String strNewPPS   = ApexPages.currentPage().getParameters().get('pps');
        if(strNewPPS != null){
            strNewPPS = strNewPPS.normalizeSpace();
            strNewPPS = strNewPPS.contains(',') ? strNewPPS.replace(',', '.') : strNewPPS;
            strNewPPs = strNewPPS.right(strNewPPs.length()-3);
            system.debug('### strNewPPS: ' + strNewPPS);
        mOpportunity.fcNew_PPS__c    = strNewPPS != null ? Decimal.valueOf(strNewPPS) : null;

But now I get the same error but this time the value is 12.34, it is still giving an error no matterwhat I put in it. How can I pass this value in the URL without getting this error???
Did you try encoding the values into URL format?
No actually I didn't. Should I encode only the field or the entire url string ???
So when you click the link what is the URL that is being passed?
I did something similar as you,


and the URL that is passed is this:

Are you getting something similar to this?
I think I found your issue. so in your link:

try doing this:


Then check to see if you are still getting the ',' or not. Let me know how it turns out.