I have an opportunity custom button and an Apex web service. When the button is clicked I want to pass Opportunity.Amount to the web service method, but it gives this error:
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:''$49,432.73' is not a valid value for the type xsd:decimal', }
This is my custom button code:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var retVal = sforce.apex.execute("WSclassname", "WSmethod", {oppAmt:"{!Opportunity.Amount}"});
alert (retVal) ;
window.location.reload() ;
This is my web service method definition:
webService static String WSmethod(Decimal oppAmt) {}
Thanks for the help!
2 respostas
David,
you can try using the VALUE function to get the decimal value from the currency field before passing it to the webservice method.{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var amt = {!VALUE(TEXT(Opportunity.Amount))};
var retVal = sforce.apex.execute("WSclassname", "WSmethod", {oppAmt:amt});
alert (retVal) ;
window.location.reload() ;