Template Nested Start expressions - can inner expression reference value from outer Start?

Background

I have an Order which lists Ordered Kits and Ordered Products. A kit contains a pre-defined list of parts derived from products. A Kit is ordered at the Kit level and when saved, a workflow populates the list of parts into the Order Products table. It may be that not all parts need to be ordered so they can be removed from the Order Products list. AND it may be that other parts are ordered and included in the Ordered Products list.

Invoicing

On the invoice I want to show:

  1. a table with the Ordered Kit level details
  2. A table beneath the Kit details with the list of ordered parts from the kit
  3. Repeat 1) and 2) for each additional Kit
  4. Finally a table with Other Products

This means I need to split the Related Ordered Products by each Kit ID and then where ISBLANK(Kit ID)


Question

In example template expression excerpt below, is there a way that [Kit] can be referenced from the outer Start row within the inner Start expression? The text is red obviously doesnโ€™t work since it references the Order row used to generate the invoice.

0 9 828
9 REPLIES 9

Steve
Platinum 4
Platinum 4

Thanks @Steve! I have seen those articles and reviewed them. Neither covers this use case.

To technically boil this down further, I am actually iterating over 2 child lists.

Oh wait, since Ordered Products referenced Kits, I might already have the list in a VC on the [Kits] table!! I should have thought of that. Sometimes you just canโ€™t see the forest right in front of you!!

They both do indeed.

To be a copycatโ€ฆNope! I didnโ€™t think it would work but thought I would try it anyway. The error returned is:

 'StartSELECT([Related Ordered Products], [Kit]=[_THISROW-1].[Kit])' is invalid due to: Error in expression '[_THISROW-1].[Order ID].[Kit]' : Unable to find column 'Kit'. 

The THISROW variables donโ€™t work in this context. [_THISROW] points to the Order row sent to the template. Order has no parent so there is nothing for [_THISROW-1] to point to. AND my Startโ€™s are operating on two child lists - one nested within the other.

[Kit] is a column within the row of the outer Start. I tried using [_THISROW] hoping it would point to the row from that list - <<Start: [Related Ordered Kits]>> - but since it doesnโ€™t, it canโ€™t fond the [Kit] column.

No matter, as I mentioned above, I have realized that I do have an already existing VC I can use in the inner Start - [Kit].[Related Ordered Products].

Well, I was wrong again. '[Kit].[Related Ordered Products]` doesnโ€™t give me what I need. I blame brain fog from staring at a computer screen too long!!

So I am back to my original question. I am trying to resolve the [Kit] = [Kit] problem but [_THISROW] wonโ€™t work. I want to avoid yet another VC in app that only serves for use when generating a PDF.

Can the inner Startโ€™s SELECT expression, through some trickery or lesser known variable, refer to a row from the outer Start?

Maybe if I change the column name of my Order Kits row to [Ordered Kit], the SELECT can figure out by context?

I feel like Iโ€™m blogging! Anyone want to order this gizmo from <<affiliate link>>??

So I tried [Ordered Kit] and the SELECT cannot figure out by context in the template how to resolve. Error below:

Expression 'Start[SELECT([Related Ordered Products], [Kit]=[Ordered Kit])' is invalid due to: Expression refers to undefined field.

So I guess I have to implement a VC after all!

Arenโ€™t you missing something in your SELECT here?
Like:

SELECT([Related Ordered Products][key-column]...

Maybe. I just discovered in a different SELECT I was missing exactly that. Iโ€™ll try it again. I guess I assumed the field the error was referring to was [Ordered Kit].

Hi Willow - did you get this sorted?

Top Labels in this Space