Use negative values returned from DME call ?

Author
Messages
mikeP
Veteran Member
Posts: 151
Veteran Member

     

    I’m working with ESS page leavebalances.htm and trying to do some math on numeric values returned from a DME call:

     

     

    function getTaemptrans()

    {

        var obj = new DMEObject(authUser.prodline, "taemptrans");

        obj.out = "JAVASCRIPT";

        obj.index = "ttrset1";

        obj.field = "company;employee;plan;ta-hours";

        obj.key = authUser.company+"="+Employee;

        obj.debug = false;

        obj.otmmax = "1";

        obj.select = "status<9&tran-type=3";

        obj.max = "600";

        DME(obj,"jsreturn");

    }

     

     

     The “jsreturn” in the call is a hidden frame, and the results of the DME are returned into “jsreturn.record.”

     

     

     If I run the DME’s url in IE, I get this:

     

    COMPANY,EMPLOYEE,PLAN,TA-HOURS

    2082,129293,"ACCFAMLI",5.400000

    2082,129293,"FAMILY",-5.400000

     

    The problem is the -5.40000 in the last field of the second returned record.  Above, it is a numeric value (not in quotes) with leading sign.

     

     

    However, it appears as string with trailing sign in jsreturn.record:

     

    ta_hours          "           5.400000-"

     

     

    I need to add this to another value, but javascript does not consider this a number, and from what I can tell, there’s nothing built into to work with or convert string values with trailing signs.

     

    Short of writing a function to parse it manually, I’m out of ideas.  How do you deal with negative numbers returned from a DME to a javascript object?

     

    mikeP
    Veteran Member
    Posts: 151
    Veteran Member

      Turns out that Lawson provides a setValue() function in esscommon80.js that I found by accident.  It has a comment: “Converts a string of "5-" to a number -5”, which does not appear to be true

       

      The typeof functions shows the return value to be a string which must be transformed into a number before adding it to another value.    I found a couple ways to do that. First, by multiplying it by 1, second by using parseFloat.

       

      There’s a reason for strongly typed languages.

       

       

      ---