Client Side API Negative Numbers

Has anyone come across an issue with using the client side API and negative numbers? We have a custom integer field under the quote entity which can contain either positive or negative numbers. However the following code:

var margin = parseInt(crm.fields("quot_c_margin").value());

seems to remove the signage so if the value of the field is -87 then 87 is returned. The strange thing is that when the quote is in read mode the signage is removed, however when the quote is in edit mode (by selecting the Change Summary button) the value is returned as expected with the correct signage.

I have tried removing parseInt but this seems to make no difference.

  • 0

    Aye, I can replicate this - and I can see why it's doing it.

    Right here in Z010_crmAPICore.js is the problem:

    rNotNumbers is a Regex, and is '/[^0-9]/g' - which means exactly what it threatens; anything that's not in the range 0-9 is going in the bin.

    In Edit mode, however, the API is far more cavalier in attitude:

    Unless I can think of a clever way of modifying that Regex at runtime (which I probably can't) then I guess you'd have to test the Mode and do either:

    var thing = parseInt(crm.fields("comp_testint").val(), 10);
    in Edit, or
    var thang = parseInt($('#_HIDDENcomp_testint').val(), 10);
    in View.