Referencing Parent Record Fields From Within Child Record Lo

Posted by Rollbase User on 13-Dec-2011 16:16

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

All Replies

Posted by Admin on 13-Dec-2011 17:21

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.

Posted by Admin on 13-Dec-2011 19:35

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?

Posted by Admin on 13-Dec-2011 23:25

I'll take a second look.

Posted by Admin on 14-Dec-2011 00:45

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.



{!#LOOP_BEGIN.R41837#38680}



Notice to Appear for: {!parents_event_type}

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



{!#LOOP_END.R41837}



Piscoso Martin

Rollbase PH

Posted by Admin on 14-Dec-2011 06:05

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

Mike

Pavel

Martin



New Years Eve Party

Pavel

Martin

Posted by Admin on 14-Dec-2011 11:15

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



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

Posted by Admin on 14-Dec-2011 16:35

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 :-)

Posted by Admin on 14-Dec-2011 17:07

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 =)

Posted by Admin on 14-Dec-2011 17:12

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.

Posted by Admin on 14-Dec-2011 17:28

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.



{!#LOOP_BEGIN.R41837#38680}



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



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



{!#LOOP_END.R41837}



------ 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.

Posted by Admin on 14-Dec-2011 18:45

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

Posted by Admin on 14-Dec-2011 19:27

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

Martin

Pavel



Sch Event: New Years Eve Party

Invited Parties: Mike

Martin



The process is driv

Posted by Admin on 14-Dec-2011 22:17

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

{!#LOOP_BEGIN.R41837#38680}

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

{!#LOOP_END.R41837}



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:

{!invited_parties}





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



Hope this solves it ^_^

Piscoso Martin

Rollbase PH

Posted by Admin on 17-Dec-2011 13:34

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

This thread is closed