Accessing dates from related apps in calculation field
Hi,
I would like to have in APP A a calculation field (in the new date format) that shows the content of a date field from related APP B.
If it's the calculation field and date field are in the same app it's easy : @date field
Does somebody knows how to do this?
-
Hi Marcos,
some questions:
1. Is the calculation field in App B?
2. Which field type is Fecha Pre-Aprobación - a text field of a "normal" date field?
3. If calculation field in B: Is there only 1 A-item related or multiple?
4. Is @All of Fecha Pre-Aprobación (in the moment() function) blue?Rainer
-
Rainer,
1. Is the calculation field in App B? => Yes, it is
2. Which field type is Fecha Pre-Aprobación - a text field of a "normal" date field? => It´s a normal date field
3. If calculation field in B: Is there only 1 A-item related or multiple? => It´s multiple. Actually, when i´m about to select the field it shows me the same field "incomming" and "outcomming". Could this be a problem?
4. Is @All of Fecha Pre-Aprobación (in the moment() function) blue? => Yes, it is in blueThanks in advance!
-
ok, I see. 2 issues:
1. Incoming and Outgoing are different, you have to select the right reference. Via Outgoing you get those A-items which you have added in the relationship field in the B-time. Incoming are those where this B-item is added in a relationship field in A.
One tip: Try to avoid vice versa relationships, in my opinion in 99% of the cases it's unnecessary to have vice versa relations (for me it's bad app design).
2. If there are multiple items related through the reference you've selected (outgoing/incoming) @all of Fecha Pre-Aprobación returns all related dates in one array, something like ["01/05/2017", "02/05/2017","03/052017"]. If you make it a string with .toString() the string looks like "01/05/2017, 02/05/2017,03/052017" - and for the function .moment() that's an invalid date and it returns 31/12/1969. If there is only one item related .moment( @all of Fecha Pre-Aprobación.toString()).toDate() should return the right result. So you have to select one date from the array which should be shown in the calcualtion field, e.g
@all of Fecha Pre-Aprobación[0] is the oldest of the related item (= the one of the related items which has been createdf first)
@all of Fecha Pre-Aprobación [ @all of Fecha Pre-Aprobación.length-1] is the newest created.
Rainer -
Rainer, think i´ve got it!
The thing is that i had several relationships between two apps. The change i made is that i select @all of... with nulls outcoming.
That made the difference... I don´t have knowledge about javascript or other languages so this is everything new.
Is it a bad thing to do, to have incoming and outcomming relations between apps? I´m trying to understand to avoid future issues.
Eg:
Sometimes, make templates like this:
App A: Contacts
- Field Name
- Related field with project (so i can select multiple projects at one time)
App B: Project
- Field Title
- Related field with contacts (so i can select multiple contacts at one time)
See my point?
-
Rainer, you answered me before i asked! :) Thanks!
I´ve checked and, in this case, i don´t have related fields on both sides (vice versa).
The thing is that some of the information or fields in app B are used in calculation fields of app A.
Other thing, would i use @all of... with nulls? when do you sugest to use it?
-
@all of .. with nulls is only necessary if you want to match/concatenate/combine 2 or more fields from App A in a calculation in App B, e.g in a for-loop. If you only want to pull from one field (like in your example) it's not necessary. But if you use array ... with nulls in loops you have to get the elements with [i][0], not only [i]. The reason: ... with nulls returns the items in a nested array:
[["01/05/2017"], [],["02/05/2017"],[],["03/052017"]]
Please sign in to leave a comment.
Comments
8 comments