Referencing Parent Record Fields From Within Child Record Loops - Forum - Rollbase - Progress Community

Referencing Parent Record Fields From Within Child Record Loops


Referencing Parent Record Fields From Within Child Record Loops

  • Given that Party objects are related to Event objects... and I need to generate a document for each Party... with respect to the following "Template" code: {!#LOOP_BEGIN.R41837#38680} Notice to Appear for: {!event_type#value} Party: {!R41837.firstName} {!R41837.lastName} {!#LOOP_END.R41837} How should I qualify the {!event_type#value} reference... so the event_type is derived from the Party's parent Event record? -Mike
  • Try prefix parent record tokens with object name. If that will not help I would recommend using JavaScript formula and storing these values in variables.
  • Thanks Pavel...

    Prefixing with the object name didn't help/work. I'm not sure what you mean when you say:

    " using JavaScript formula and storing these values in variables."

    Could you please provide an example?
  • I'll take a second look.
  • Hi Mike,

    You can create a related field on your child object (Party) which is linked to it's parent Event's event type. You can then use its integration code in your loop.


    Notice to Appear for: {!parents_event_type}

    Party: {!R41837.firstName} {!R41837.lastName}


    Piscoso Martin

    Rollbase PH
  • Thanks Pavel...

    Thanks Martin... I shouldn't have used the term "parent" above. What I need is access to fields from the record which is "current" with respect to the outer loop. E.g.

    Christmas Party




    New Years Eve Party



  • Pavel... could you please detail/provide an example of what you wrote above/mean by:

    " using JavaScript formula and storing these values in variables."
  • Not that anyone is still following this... but...

    I can get the desired output by adding javascript to the outer loop to save the referenced token values... then, use javascript within the inner loop to write those saved values... very cool... but...

    PROBLEM... the above only works if I do not "render as PDF." This is getting silly.

    Pavel, Matt, someone... a little help please :-)
  • Hi Mike,

    If you wan't to render as pdf and is already getting the values from javascript, create a formula field and put your code there then use the token from your newly created field in your loop :)

    In case this doesn't work, can you provide a more detailed explanation?

    Q: Your running a Loop of the party's attendees or a loop of the event itself?

    Thanks =)
  • I think this is what Pavel was referring to as - " using JavaScript formula and storing these values in variables." - use your javascript code and place it within a formula type of field then call that within the loop.
  • Sorry I'm not/can't be more clear... but, all I'm trying to do is reference fields from the outer loop from within the inner loop. E.g.

    Original Issue


    ------ document template content below ------

    This token {!event_type#value} will print here... in the outer loop.


    This token {!event_type#value} will NOT print here... in the inner loop.

    These tokens {!R41837.firstName} {!R41837.lastName} print.


    ------ document template content ends ------

    So, instead of trying to print the outer loop value via its token... I added script to the outer loop to save the value in a variable. Then, I print the variable's value in the inner loop.

    This works... unless I render as PDF.

    As to using formula fields... i.e. adding fields to the inner loop object... that won't work, as I explained a couple of posts back.

    Thanks to all.
  • Hi,

    The reason why event_type won't print in your loop is because it's a "Related" Loop as signified by the loopbegin token (see below):

    {!#LOOP_BEGIN.R41837#38680} <

    {!event_type#value} inside the loop is not from the same object (correct me if i'm wrong). You will need to reference the {!event_type#value} field from the 'same' object. Notice that you used {!R41837.firstName} {!R41837.lastName} to print the first and last names. if the field event_type is already in the same object, then to print it you should have used {!R41837.event_type#value}.

    As for formulas, I don't see why this wont work since formula fields more often than not can handle rigorous code.

    Example using your scenario:

    So coming from the "inner" object, you have to Get the value of event_type if it's not from the same object, hence either related field referencing the relationship and the field in question (event_type) OR you can use a f
  • The outer loop is based on the Sch Event object... i.e. looping through Sch Event records selected from a Sch Events list. The inner loop is based on Party records related to the above mentioned Sch Events.

    If you are suggesting that I add a Formula field to the Party object... that will not work. The reason that will not work, if that is what you are suggesting, is that Sch Events/Parties have a many-to-many relationship.

    What I need to output from within the inner loop is the {!event_type} related to the Sch Event record which is "currently in scope" re the outer loop... which, of course, can/will only be one of perhaps many which may be related to the Party which is currently in scope re the inner loop.

    As I posted above... one can visualize the data as follows:

    Sch Event: Christmas Party

    Invited Parties: Mike



    Sch Event: New Years Eve Party

    Invited Parties: Mike


    The process is driv
  • Ok, i think i got the grasp of your problem here.

    Try adding a template (template text) field in the 'outer' loop's object (Sch Event) which contains a loop of related invited parties.

    It's going to be the same as what your using now (inner loop) something like:

    Field name : Invited Parties

    Field Type : Template


    {!R41837.firstName} {!R41837.lastName}


    integration code: invited_parties

    This should fix your problem.

    Now instead of using an inner loop, use the new template field that you created.

    Something like this:

    Event: {!name#text}

    Event Type: {!event_type#value}

    Invited Parties:


    This should work also in 'render as PDF' mode for HTML templates.

    Hope this solves it ^_^

    Piscoso Martin

    Rollbase PH
  • This should work now: use object name as prefix to refer to parent record withing a loop.