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
bz880bz880 

AJAX toolkit not bringing back 0.00

Hi there,

I was trying to update some opportunity line item fields with a value of 0.00. This works no problem through the standard SalesForce edit screen. However, when this opportunity is retrieved through the AJAX API, no values are being returned to me.

Has anyone else dealt with something like that?

Thanks
Baldwin
Ron HessRon Hess
which version of the AJAX toolkit ?
do you get back a "null" , an error or what ?

is there a queryResult with the size you expected, but no amount ?

did you use queryResult.results[0].get("Amount") ? or queryResult.results[0].Amount ?
bz880bz880
I am using v2 of the AJAX toolkit. I am getting back a empty string. There is no null error.

I am simply doing an sforce query like such:

var lineItem = sforceClient.Query("Select foo from OpportunityLineItem");

Then to retrieve a value, I call

lineItem.records[0].get("foo");

When I do an alert of foo, it is an empty string.


Does this make it clearer?
Ron HessRon Hess
yeah, i'll try to step thru this and see if it's a problem casting 0.00 to string.
thanks
Ron HessRon Hess
I get the same thing, if the opportunity amount is 0.01 i get back a currency, if it is 0.00 i get back "not set"

will file a bug.
bz880bz880
Can you suggest a workaround until the bug is fixed?

Is the SOAP response contain an nill, or empty element, or is the AJAX toolkit simply not parsing it correctly?

Thanks
Ron HessRon Hess
workaround suggestion,
if you ask for the Amount to be returned, and you get back a valid query response but the amount is not set ( try , == undefined or == null )
then the amount was 0.00$

i believe the problem is that a number 0 cast to a string is "" which is not set into the AJAX return object.
bz880bz880
I did a little more debugging in the toolkit. The problem happens when setting a new instanstiating a new Property object. By doing the following:

var _value = value || "";

Javascript does not evaluate a float of 0 as valid. So the "" is satisfied. I went with a workaround like this:

if(value == null)
_value = "";


Baldwin