How can I access the [row_key] that fired a s...

expressions
(Jonas /) #1

How can I access the [row_key] that fired a specific PDF_creation for scheduled reports inside start: expressions?

I run a scheduled report for each row in table (+condition) I can access the values of the row that invoked the PDF_Creation by using [_thisrow].[row_key] but when I use start: expressions [_thisrow].[row_key] now refers to the table that is used inside the start.

How can I select the [_invoking_row_key] inside of Start: expressions?

-thx

(Philip Garrett) #2

@Jonas

Hi Jonas,

Thanks for the clarifying images.

You wrote “How can I access the row of “monthly_drivers” that triggered the workflow inside the start: expression? [_THISROW].[month] does not work since it looks inside of “tours” instead of “monthly_drivers””.

Actually, when [_THISROW] appears inside a Start expression like the one below, it refers to the current row of “monthly_drivers”. Admittedly, the term [_THISROW] is a

bit confusing, but it is referring to the current row of the table containing the Start expression. That is “monthly_drivers” in your example.

To verify this, I did the following: 1. I created two tables that contain the fields listed in your image.

  1. I created a Report for table “monthly_drivers” that specifies “For each row in table”.

  2. I created a Body template that contain the test template shown below.

  3. I saved and verifying the template.

  4. I ran the Report

Report For monthly_drivers

driver: <<[driver]>> year: <<[year]>> month: <<[month]>> is_ready: <<[is_ready]>>

<<Start: SELECT(tours[id],[_THISROW].[month]=”Jan”)>>

Driver1: <<[driver_1]>> Driver2: <<[driver_2]>> Driver3: <<[driver_3]>> Driver4: <<[driver_4]>>

<>

The Start: SELECT expression condition I specified is not realistic, but it confirms that [_THISROW] is referring to the current row of “monthly_drivers” and that it retrieves the value of the “month” field in that row.

Forgive me if I have misunderstood what you are reporting. If so, please do the following:

  1. Create an simple sample app that illustrates the problem. 2. Provide me with: 2a. Your account id from the Account pane 2b. The app name 2c. The steps to reproduce the problem.
(Philip Garrett) #3

@Jonas

If you are referring to the [row_key] inside a SELECT expression, then you should specify [_THISROW].[keyA] to refer to the key of table A.

For example:

Start: SELECT(B[keyB], AND(IN([keyB],[_THISROW].[RefColumnInAThatRefersToB]), [SomeFieldInB]=“Active”))

In a SELECT expression, the table you specify in the first part of the SELECT (in this case “B[keyB]”) determines which table is the current table in the second part of the SELECT expression.

For example, if you want to refer to a field in B in the second part of the SELECT expression, you simply specify the field name from B. In the example above I refer to [SomeFieldInB].

If you want to refer to a field in A in the second part of the SELECT expression, you specify [_THISROW].[SomeFieldInA]

SELECT and FILTER are special because the first part of the SELECT picks the table that is used as the default table throughout the second part of the SELECT expression. In the second part of the SELECT expression [_THISROW] is used to refer “up to the parent table”.

(Jonas /) #4

@Levent_KULACOGLU @Philip_Garrett_Appsh thank you for your answers. I understand the select() and how I can use table A & B to connect within that statement. My scenario is that I want to get the specific row that invoked the PDF.

Please check out these 2 attachments, they are a bit simplified but visualize the situation.

(Jonas /) #5
(Jonas /) #6

@Philip_Garrett_Appsh

You are right, your example works for the select of the start expression. The problem occurs, once we are inside of it.

Try this and you will see that you cant get out of the start expression.

edited_ Report For monthly_drivers

driver: <<[driver]>> year: <<[year]>> month: <<[month]>> is_ready: <<[is_ready]>>

<<Start: SELECT(tours[id],[_THISROW].[month]=”Jan”)>>

is_ready: <<[_thisrow].[is_ready]>>

<>

-------------------- I also tried using the column name alone without the

[_thisrow] but then I get “couldnt find column”

(Philip Garrett) #7

@Jonas

Hi Jonas,

If you want to refer to fields in the parent record from within the embedded template of the child record, the child record must contain a Ref field that refers to the parent record.

In your case, you need a Ref in the “tours” table that refers to the parent record in the “monthly_drivers” table.

If that Ref field was called “monthly_driver-ref”, then within the embedded template for the “tours” table you could access the “is_ready” field in “monthly_driver” by specifying:

[monthly_driver-ref].[is_ready].

[_THISROW] is only defined within the right hand side of the SELECT expression where it refers to the parent record.

[_THISROW] is not defined within the embedded template. As you noted, specifying [_THISROW].[is_ready] will not return the value of the “is_ready” field in the parent record in the embedded template.

Instead, you need to use a dereference expression like [monthly_driver-ref].[is_ready].

(Jonas /) #8

that’s unfortunate,

thy

(Levent KULAÇOĞLU) #9

@Jonas using a de-ref expression without a dot in between should fetch it, i.e.

[RelatedTableRefColumn][Row_Key]

(Jonas /) #10

Table_A = invokes PDF_create Table_B

= used for start: expression

between A and B there is no ref_column.

So I don’t see how I can really use what you’re suggesting.

(Levent KULAÇOĞLU) #11

@Jonas I thought that you have ref between 2 tables, therefore I proposed that. Without a ref, may be you can fetch the ID with ANY(SELECT(…)) expression. But of course this will only work if you have some kinda connection (not ref) between 2 tables.