merge syntax within merge syntax?

  • 1
  • Question
  • Updated 3 years ago
Can we do something like this?

{{$Model.MyModel.data.{{$Model.MyModel.data.length}}.MyField}}


Perhaps I should just use javascript...
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I think I asked this once. I don't it's possible. What are you trying to do?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hmm, looks like I'm going to want javascript anyway... too many conditionals.

I need to add the values of a bunch of fields on a related model into the text of a field. Problem is I don't know how many rows will be on the related model.

Basically, I have a text field whose value should read "Tested for {{$Model.STD_Tests.data.ALLROWS.STD__c}}(s)" ... except that I don't think anything like ALLROWS exists?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
That should work where you use a component that has a related model. Especially if you use a child relationship in the model. Yup. That'll work.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Wait... what will work?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You have two objects you're working with. The first is something that is parent to STD Tests.
So, create model pointing to this parent model. Add a child relationship to the STD Tests object. Drag this child relationship onto a field editor or table component. Choose field(s) that represent the STD Test.

If you don't want all STD Tests to show up in the Child Relationship, then set a condition on it. ie. Field IsTested is True.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Nested merge syntax within a particular piece of merge syntax is not supported --- you must close out one merge before starting another merge.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Pat,

The problem is, I'm not trying to simply display the data. I'm trying to add the values to a text string (which isn't on the parent model).

I'm trying to automate the creation of a "Nurse's Note," which ends up being a giant blob of text created from the values of a bunch of fields on several different models. That way we still have the Note in the format that the docs want it in, but my users don't have to write down in a large text field a bunch of the data they've already captured.
(Edited)
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Use a custom renderer?