Use text fields of app reference in calculation




  • Pieterjan M.

    Hi everyone,

    as this was very important for our organisation I had to made an in between solution. Basically I convert a textstring to a number with a simple function. I then use that number in a calculation field of another app to transform it to text again.

    See the screenshots to get an idea of what it does, I reused the same example as mentioned above.
    - Participant app:
    - Person app:
    - Activity app:
    - Internals Participant app:

    Here is the javascript code

    Part 1:

    function string_to_number(input_text, part){
      part = (part === undefined) ? 1 : part;
      var encoding = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.()1234567890@",
          letters = input_text.split(''),
          output_number = 0,
          exp = Math.min(14, 2 * (( letters.length - (part-1)*8 )-1) );
      for(var c = 0+(part-1)*8; c < Math.min(letters.length, part*8); c++){
        var spot = encoding.indexOf(letters[c]);
        output_number += (spot+10)*Math.pow(10, exp);
        exp -= 2;
      return output_number;
    string_to_number( Child Name , 1);

    Part 2:
    function number_to_string(){
    var total_input = '',
    encoding = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-.()1234567890@".split(''),
    output = '';

    for (var i = 0; i < arguments.length; i++) {
    total_input += arguments[i].toString();

    var letters = total_input.split('');

    for(var i=0; i+1< letters.length; i+=2){
    var position = parseInt(letters[i]+letters[i+1]);
    var character = encoding[position-10];
    if(character) output += character;

    return output;

    number_to_string( Sum of Act n1, Sum of Act n2, Sum of Act n3)+' - '+number_to_string( Sum of Person n1, Sum of Person n2, Sum of Person n3)

    Let me know what you think about it, and even better, provide an easier solution to achieve the same goal ;).

    (limitations of this approach, I can only store 16 digits in an integer so I can only persist 8 text characters at a time. That's why I use 3 number fields to higher that number to 24 text characters. My experiments to work with Fixed (decimal) numbers failed).

    Comment actions Permalink
  • Hey Pieterjan,

    This is definitely something we will consider to add in the future :)

    Sara - Podio

    Comment actions Permalink
  • Pieterjan M.

    Thanks Sara, you already have your first user!

    Comment actions Permalink
  • Eduardo Cruz

    Hi Pieterjan, et all,

    This workaround will be a great help, if I can make it work...

    Problem is that I'm not getting the 2 last characters into the final number (output_number).

    I give you an example: having in the starting text field the word "Processo", when I convert it to a number, I should get 5228251315292925.
    But I'm getting 5228251315290000, meaning that the latter ("so") are not getting translated.

    I ran several checks on the code and everything looks perfect. When I run this code outside Podio, it calculates fine.

    So, I think this is a Podio specific problem...

    Any hint?


    Comment actions Permalink
  • Pieterjan M.

    Hi eduardo,

    it's normal that Podio stops after 6 letters because a float in podio can max have around 12 digits (and 4 decimals which I tried to use to store information but didn't work).

    The solution is already in the javascript. You need to use multiple number fields to transform your one text field.
    So make for example 2 number fields, with twice the same code as you find in part 1. The first number field is Child n1

     // all the other string_to_number  JS code
     string_to_number( Child Name , 1);

    and the second Child n2

     // all the other string_to_number JS code
     string_to_number( Child Name , 2);

    Then in the item where you want the string do

     // number to string JS code
     number_to_string( Avg of Child 1, Avg of Child n2)

    Let me know if it works :), and I'm working on an even much simpler solution that I will open source soon. Stay tuned!

    Comment actions Permalink
  • Dan Stroehlein

    This now works without the workaround...The other fields in the app reference can be used in the calculation. Use the @ symbol and then start typing the name of the field and it will display [ ] All of.............; it works great! Thanks Podio this is huge!

    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk