conditional calculation between 2 apps
Hello everyone,
I'm wondering whether someone could help me out with the right syntax?
Case:
I have 2 apps - APP1 contains all the dates of 1 school year on which I can register a child to school. APP2 contains a birthdate and a calculation field that eventually should calculate the closest date that I can register my child to school. You can register for school at the age of 2,5y (30 months) - so what I need is the following:
STEP 1: birthdate (app2) + 30 months = ResultDate
STEP 2: compare the ResultDate with the closest register date from app1
STEP 3: show the closest date in the calculation field (app2)
So to give a concrete example:
My child is born on 13/09/2021. On 13/03/2023 it will become 2,5 years old and as of then, I can register my child to school. In the 2nd app I have 6 dates being 01/09/22, 07/11/22, 09/01/23, 27/02/23, 17/04/23 and 22/05/23. From the logic explained above the closest date after the child has become 30m would be 17/04/23. This is the date that I would like to get back in the calculation field.
Can anyone give me a hand on the syntax, please?
Many thanks in advance...
Benny
-
HI Benny,
the calculation is no problem, it could be something like this (where I assume that the birth date is in a date field):
var bdplus = moment(@Your Birthdate field).add(30,"months")
var registerdates = ["01/09/22", "07/11/22", "09/01/23", "27/02/23", "17/04/23","22/05/23"];
date = ""
for(i = 0; i < registerdates.length; i++){
day = moment(registerdates[i],"DD/MM/YY");
if(day >= bdplus){
date = registerdates[i];
break;
}
}
dateThe question is, how you get the register dates from app 1. If you want to pull data from other items (in the same app or in another app) there must be a connection between the items via a relationship field. Do you have a relationship field in app 2 to app 1? If so how do you set the relation between the items? Do you use Podio Advanced workflows (aka Globiflow)? Is each registration date an own item in app 1?
I need to know these things for giving you the correct code.
Btw: In your example none of the 6 registration dates would be matched because (born on) 13/09/2021 plus 30 months = 13/03/2024 , not 2023 :)Rainer
-
Hi Rainer,
Many thanks for your quick response :-)
As to what I understand from the syntax (and please correct me if I'm wrong) is that you declare the registration dates as hard variables in the coding, right? this means with your syntax there is no need for a second app. In the 2nd app, I only have 2 fields: the registration data (date) and a description (text). Nevertheless, if I only have to add a few new dates in the coding on a yearly basis, maybe this is easier to maintain than going through all the hassle of connecting 2 apps to each other?
I'm using Globiflow as well but was not yet able to figure out how I configure it correctly.
P.S. you're absolutely right in my example the result would probably by NULL as I missed 1 year ;-)
Benny
-
Hi Rainer,
I tried your syntax (see screenshot) but as you already explained it didn't give me any results as the calculated date is beyond any of the hardcoded options. So, I added a fictive date 01/04/24 to the list which is beyond the calculation date to see whether he would return this date. Unfortunately, Podio is giving the following error message "Invalid value "01/04/24" (string): must be number" back.
Can you point me in the right direction, please?
Many thanks ...
B.
Please sign in to leave a comment.
Comments
3 comments