Unique ID field as a number field

Answered

Comments

17 comments

  • Christopher Abalos

    Hi Hamid,

    Try using the parseInt() javascript function to convert from a string into an integer.

    var num_id = parseInt(@Unique ID, 10);

    http://www.w3schools.com/jsref/jsref_parseint.asp

    1
    Comment actions Permalink
  • Hamid

    Hi Christopher,
    Thank's for your response, I try the parseInt() function but i have "the result is an invalid number" when i do num_id+@mynumber.

    the solution is to add this " " to the end of the calculation, but the field is converted to text !

    var num_id = parseInt(@Unique ID, 10);
    num_id + @mynumber+ " "

    0
    Comment actions Permalink
  • Christopher Abalos

    Hi Hamid,

    Are you sure @mynumber is a number field? You might want to also try wrapping that in a parseInt to see what happens. You could also try and see what happens if you return "numid" by itself.

    0
    Comment actions Permalink
  • Hamid

    @Christopher,
    - mynumber is a number field.
    - return numid itself give "the result is not a valid number".
    - I use paseInt(@mynumber, 10); and return it itself then it give me a true result.
    - But when i add mynumber to numid it return invalid result !

    var numid = parseInt(@Unique ID, 10);
    var nombre = parseInt(mynumber, 10);
    mynumber + numid

    the result is not a valid number<<<

    0
    Comment actions Permalink
  • Christopher Abalos

    Hamid,

    Does the Unique ID have anything other than number characters in it? Does it maybe have a prefix set on it like AB123?

    0
    Comment actions Permalink
  • Hamid

    Christopher,
    No, The ID have not a prefix and it's length is on 1

    0
    Comment actions Permalink
  • Christopher Abalos

    Hamid,

    Hmm. Very strange. I noticed in your one example that there might be a typo.

    var numid = parseInt(@Unique ID, 10);
    var nombre = parseInt(mynumber, 10);
    mynumber + numid

    It should be mynumber + nombre

    Unfortunately if this doesn't fix it, I'm out of ideas. Hopefully someone else will have an idea.

    0
    Comment actions Permalink
  • Hamid

    there is a snap of my exemple :
    NB : I am in french version of Podio // sory for my bad english :)
    no prefix : http://ovh.to/cQbr7Ur
    the calculation : http://ovh.to/qKzJ28h

    Thank you Christopher for your Help.

    0
    Comment actions Permalink
  • Christopher Abalos

    Just out of curiosity, are you editing this template while inside of an item? If you edit a template when you're not inside of an item it uses placeholders for all the fields in the app. I think Podio might use character prefixes in their placeholder values for the Unique ID's. Let me know if this makes sense.

    0
    Comment actions Permalink
  • Hamid

    Yes I am inside an item,
    Look at this snap (i have a result in "Calcul ID2") : http://ovh.to/QstXuqd

    0
    Comment actions Permalink
  • Christopher Abalos

    Maybe try wrapping nombre + numid in a parseInt.

    parseInt(nombre + numid, 10)

    0
    Comment actions Permalink
  • Hamid

    same problem when parseInt() the result
    invalid number
    if ai add " " it work !!!

    0
    Comment actions Permalink
  • David Gélinas

    You made this work? Can you share the final code?

    I'm really stuck with this. One of my implementation of Podio is stuck on this little pebble.

    0
    Comment actions Permalink
  • Hamid

    Hi David,
    I am using the following formula in a proposal app to create an automatic numbring combined with the date (Month/Year) and the UniqueID wtith an initial value of an existing proposals :

    
    var date = moment(@Date).format('YYMM');
    var compteur = 865
    var id = parseInt(@UniqueID, 10)+ compteur; 
    date+id
    
    

    This guive me : 1502866, 1502867 ...
    15 ==> for Year
    02 ==> for Month
    866 ==> Autonumbring incrementing by one each new proposal
    @Date is a date field in the app
    /Hamid

    1
    Comment actions Permalink
  • Jinne Stiksma

    Thanks Hamid! Long search over. That works.

    0
    Comment actions Permalink
  • Marc Naidu

    Thanks @hamid, @Christopher, @David,

     

    That saved me tons of time. @unique field is a strange one ... could not convert it to a number field as well!

     

    Marc

    0
    Comment actions Permalink
  • joel lowery

    Try this. It worked for me. For some reason, it wouldn't work without the parseInt(0) + @Unique ID being added first.

    NOTE: You must make sure your calculated field is number first. 

    var x = parseInt(0) + @Unique ID
    parseInt(x,10)

    1
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk