2 followers Follow

Update items of the same app with field calculations

Hi everyone, I have an app A with thousands of items as follows: Name (related from App B), Course (related from App C), Date (related from App C). I would need the text "Checked" to appear in a calculation field when a previous item, having the same Name, has a higher date and a Course belonging to a group. In the example the groups are as follows: Group A: PS02 and PS01 Group B: ANT01 and ANT02


Claudio Calabrò

Please sign in to leave a comment.



Hi Claudio,

you need another app D for achieving that. I call those apps "Helper" or "Background" apps. D can be in whatever workspace and is an app which shouldn't be touched by users.

These are the main steps:

  1. Create the app D with 2 fields: Title and a calculation field called "Checker", enter @unique id in the calculation field. Save the template and create 1 item with title f.ex. Course check (you can enter whatever you  want).

  2. In your app A:
    - add a relationship field which points to app D, name it "D-Relation",
    - add calculation field "Check Line" and enter:
       var name = @all of name.toString();
       var group = @all of course.toString().replace(/[0-9]/g,"") == "PS" ? "A" : "B";
       var date = moment(@max of date).format("YYYYMMDD");
       group + ":" + name + "|" + date + "|x" + @unique id + "x"

      Both fields can be always hidden.

  3. Create a flow in Globiflow, App A:
    When item created
    update this App A item in field
    D-Relation = App Item ID -> select App D, App item ID = 1
    Save the flow. 

  4. Click the dropdown besides "Edit", click Run, enter 0, click ok.
    And then wait. The run of the flow connects each existing A-Item with the one D-item and will connect each new A-item. For thousands of items it can take hours. And it can happen that the flows stops after some hours (4 or 5), that would be the case if  there are more than about 7,000 items in app A (but can also happen with less items, cause there are some parameters which determine the speed of the flow). If the flow stops, don't click run again. You then need to create a view which filters all A-items with "not set" in the relationship field, then you need to run a flow "Get view", for each, update the relationship field. For with a Get view you can update max 1000 in one run.    
  5. After all existing items are related to D go to app D, modify template
    Remove @unique id and enter:
var array = @all of check line;
var checked = [];
for(var i = 0; i < array.length - 1; i++){
s_0 = array[i].split("|");
n_0 = s_0[0];
d_0 = Number(s_0[1]) || 0;
id_0 = s_0[2];
s_1 = array[i+1].split("|");
n_1 = s_1[0];
d_1 = Number(s_1[1]) || 0;
id_1 = s_1[2];
    if(n_0 == n_1 && d_0 < d_1) {

The result is a large string with the unique ids, each between 2 x (x1x).

      6. Now in the App A create the calculation field "Check", enter:

    @all of checker.toString().indexOf("x" + @unique id + "x") > - 1 ? "checked" : ""

That's it.


Rainer Grabowski 0 votes

hello ranier,

I'm trying on a test area, sliding the passage globiflow but at point 5 (in addition to an extra brace) the calculation gives me an error: s_0 is not defined

where am I wrong?

Claudio Calabrò 0 votes

I do not explain why, but today without having changed anything, I no longer have the error.
I need at this point a last information (for now) I have two arrays @all of field 1 and @all of field 2 I would need to have a value of 1 on field calculations when even just one element in the array @ all of field 1 is present in the array @all of field 2

Claudio Calabrò 0 votes

There are multiple ways to achieve that:

var i,check,
a1 = @all of field 1,
a2 = @all of field 2,

Option 1:

check = 0;
for (var i = 0; i < a1.length; i++) {
if (a2.indexOf(a1[i]) > -1) {
check = 1;

Option 2:

check = a1.filter(function(i) { return a2.indexOf(i) != -1; });
check.length > 0 ? 1 : 0


Rainer Grabowski 0 votes

tested and works, but I still have to work on it to get what I really need.



Claudio Calabrò 0 votes