Use text fields of app reference in calculation
AnsweredHi Podio,
right now we can use numeric fields in referenced apps for calculations. However we cannot use text fields. This would be very handy in order to make unique names for your items. A quick example.
App 1 = Activities
App 2 = Persons
App 3 = Participants, if I want to use this in other apps, I need it to have a unique and easy to identify name. Putting this in a formula it would be @Activity.name + " - "+ @Person.name
Seeing what capabilities the calculation field now has I hope it is quite straightforward to also include text fields of referenced apps. Can we expect this in the future or not?
Greetings,
Pj
-
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: http://i.imgur.com/Cci8HCy.png
- Person app: http://i.imgur.com/9J6BINq.png
- Activity app: http://i.imgur.com/yGITDoG.png
- Internals Participant app: http://i.imgur.com/ycg5kPC.pngHere 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).
-
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?
Thanks,
Eduardo -
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!
Please sign in to leave a comment.
Comments
6 comments