Get parent data within a Page collection

Wybren1
Tera Guru

Hi,

 

I need help with getting the "parent" data/values (aka Form data controller) from within a page collection.

So this is for a shared "tab" between experiences that needs to get the data from the parent it's coming from.

 

Already tried: data.gform.nowRecordformBlob.table / sys_id, but this only seems to work within viewports and not within page collections.
Also tried adding URL parameters (after) I created it in the sys_ux_app_route, which crashed the page funny enough.

 

Does anybody have an idea on this?
@Brad Tilton You mentioned already you knew a solution for this 🙂

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Wybren1
Tera Guru

Alright managed to find it, not sure why it didn't work before.

Let me also make a short tutorial for it for other people!

 

Step 1
Make sure you are using the latest "record" default template.
You can tell by going to the Data Sources and check the form controller:
Old ID is called "gform", new ID is called "record" 
Old:

Wybren1_1-1690311765588.png

New:

Wybren1_2-1690311808189.png

If you still have the old one, add a new page variant and select it from template (select the latest one).
*I know both standard record and CSM default record has the new controller

Wybren1_3-1690311959397.png

Step 2
Create your page collection
Goto your newly created record page, select the "Tab sidebar"
+ Add a new tab

Wybren1_4-1690312110217.png

Select "Add a page collection", and click "Next"
And click "Create collection"

Wybren1_5-1690312185298.png

This will send you to the backend specifically "sys_ux_extension_point" table.
Click "New"
Name: Up to you
Component: Tabs
App shell: UXR Base Experience Shell (Default)
Controller: Form

Wybren1_6-1690312334272.png

Go ahead and just click "Submit"
*Just leave the page open we will change the icon in a later state.


Step 3
Go back to the UI Builder, "Refresh list"
And go ahead select your create Page collection and press "Continue"

Wybren1_7-1690312470533.png


Step 4
Let's add a tab page to actually show up within the tab.
Click on your "Page collection", and select the button "Edit Content"

Wybren1_8-1690312605443.png

This will now open a new UI Builder Tab.
Within the "Page collection" add a new page. "Create new Page"
The name is also used for the "Tab" name itself.

 

Step 5

Access the form controller data
Within the Data resources you will now see the "Inherited data resource instances" > Form

Wybren1_9-1690312907940.png

It's called "controller", for my example I've simply just used a "stylized text" to show the parent sys_id.
Simply just call them by @Data.controller.sysId and @Data.controller.table

On the page collection the "Test values" are the parent values given as an example in the controller.

Wybren1_10-1690313129442.png

Click "Save"

Step 6

Add an icon to the tab!
First go back to the tab you left open, or open the sys_ux_extension_point table.
Click your page collection open, now in the bottom you have a related list called "UX App Routes"
There is a column called "Icon", fill in the icon you want for your tab.
These can easily be found by using the "icon" component, and simply doing everything lowercase with "-"

Wybren1_13-1690313880455.png

In my case it going to be "ai-sparkle-fill"

 

AND voilà

Wybren1_14-1690314093548.png

 

Bonus step
Setting up Context props

Usually what I'd like to do is actually setting this up with the @context.props
Goto the Body on your content tree, and select "config" on the configuration pane
Click "Edit"

Wybren1_11-1690313295176.png

Click "+ Add" next to properties
Fill in Property name: parentTable (or whatever you like to name it)
Click "Add"
Click once more on "+ Add"
Property name: parentSysId
Click "Add"
Then "Save"
Now within the properties fill in the @Data.controller, for me it didn't auto fill. But you can simply add them.

Wybren1_12-1690313581589.png

After this you can now simply call them with @context.props.parentSysId and @context.props.parentTable

 

Hope this helps anybody that came across this!

View solution in original post

10 REPLIES 10

Did you add the latest record page first ? 

Johnny32
Tera Contributor

@Wybren1,
Yes, we verified that we were using the latest record default template as per step 1 in your guide. Still stuck even after trying David's suggestion below.

@Johnny32,

Just as ideas - have you cleared cache (via cache.do) - also worth closing your browser tab and reloading.  I have found certain UX Experience features do not work on initial creation and a clear down often gets things to "spring into life".

@Johnny32 hi

 

I'm banging my head on the same wall, but have just managed to get parent properties showing in my Page Collection Page.

 

My suspicion is that there may be a version issue here and suspect the "Standard Record Page" (SRP) has changed between SN version - and with it the Data Resources (types/names) embedded in it.  

 

In the example app I am looking at (an SN App installed in my instance), this has two Data Resources "Record (record)" and "UI Controller Record Page (rpCtrl)"

 

Whereas the SRP I created (in Utah) has an "Agent Assist Search Prefetch 1" and a "Form Controller (record).   

 

For my environment I had to set the "Controller" field on the "UX Extension Point" to "Form" - as this is the parent controller we need to propagate.

 

With that in place the Page with the Page Controller is now - because the "Form" Data Resource in there is called "controller" - able to reference "@data.controller.table".

 

So I think you may need to check the Data Resources in the SRP you created - select the appropriate "Controller" - as "Form" OR "UI Controller Record Page" - on the Page Collection Extension Point.

 

@David Hubbard,

Thanks for your response. When you say you had to set the "Controller" field on the "UX Extension Point" to "Form", did you mean you update the UX Extension Point that you created on step 2 of Wybren1's guide, or did you update a different UX Extension point record?

Johnny32_0-1697748091904.png

After following Wybren1's guide, the 'Controller' field was already set to 'Form' on my UX Extension Point.