+1 expression help

NCD
Silver 2
Silver 2

How do I write;

if a related grandchild record has been added +1

Solved Solved
0 7 97
1 ACCEPTED SOLUTION

I think you expression in the action that sets the values of column number in the grandparent table could be something like 

COUNT(SELECT(Grand Child Table [Grand Child table Key column], IN([Key column of Parent Table],[Related Parents column in the Grandparent Table] )))

Edit: This action can invoke on each save of the parent form but will change the count only based on number of grand child records. So if there is no addition to the grand child records, the action will simply write the same number again in the field. So you need not have any condition to invoke the action on the parent table.

View solution in original post

7 REPLIES 7

May we know where do you want to write this? Meaning which table ( grand parent , same table?) and which column - real VC etc.

Could you elaborate a bit in more detail?

This expression is going to be written in my Action;

Type: set the values of some columns in this row

Inside of, Only if this condition is true

Which is going to be attached it to a Form's Event Action to trigger when the save button is clicked.

But I DO NOT want it to +1 every time the "save" button is clicked,but only when a new grandchild's record has been added and the "save" button is clicked.

So far I've;

1) created an action set the values of some columns in this row on Grandparent table.

2) created an action execute an action on a set of rows on my Parent table (so I can put it inside my Event Action)

3) The column I want to set is just a real column, type number, named [number]

Thank you, could you add why you cannot use action in step 1 only as an event action?

Is the form on grand parent table? 

Like this;

image.png

I think you expression in the action that sets the values of column number in the grandparent table could be something like 

COUNT(SELECT(Grand Child Table [Grand Child table Key column], IN([Key column of Parent Table],[Related Parents column in the Grandparent Table] )))

Edit: This action can invoke on each save of the parent form but will change the count only based on number of grand child records. So if there is no addition to the grand child records, the action will simply write the same number again in the field. So you need not have any condition to invoke the action on the parent table.

It gives me a 0...

1)ใ€€Created an Action: Count number

  ใ€€For a record of this table: Grandparent

  ใ€€Do this: set the values of some columns in this row

  ใ€€Set these columns: number

  ใ€€COUNT(
  ใ€€SELECT(
  ใ€€Grandchild [id],
  ใ€€IN([id],[Related Parents] )
  ใ€€)
  ใ€€)

2) Created an Action:

  ใ€€For a record of this table: Parent

  ใ€€Do this: execute an action on a set of rows

  ใ€€Referenced Table: Grandparent

  ใ€€Referenced Rows: LIST(Grandparent_id)

  ใ€€Referenced Action: Count number

3) Put it in Event Actions of Form

I think I made it work by;

COUNT(
  ใ€€SELECT(
  ใ€€Grandchild [id],
  ใ€€IN([Parent_id],[Related Parents] )
  ใ€€)
  ใ€€)

 

As always, thank you very much for helping me!

Top Labels in this Space