select parent based on child value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

select parent based on child value

mbojja
Hi Alex - I'm storing this xml as a dataset using an action and pre-populate some employee details. 

<json type="object">
    <staff type="object">
       <lastName>Manish</lastName>
       <firstName>CCC</firstName>
       <departmentPositions type="array">
            <_ type="object">
                <departmentId>101111</departmentId>
                <departmentName>North East</departmentName>
                <positions type="array">
                    <_ type="object">
                        <positionTitle>Teacher</positionTitle> 
                    </_>
                 </positions>
              </_>
                  <_ type="object">
                <departmentId>101112</departmentId>
                <departmentName>South East</departmentName>
                <positions type="array">  
                    <_ type="object">        
                        <positionTitle>Principal</positionTitle>                      
                    </_>
                </positions>
            </_>
        </departmentPositions>
    </staff>
</json>

While filling the form, user selects one of the multiple positions he has got from a positions dropdown. On selection of the position(control-employee-position) I should autofill the associated departmentName in another text control

for which I'm using the following xpath as calculated value - xxf:instance('fr-dataset-staffDetails')/staff/departmentPositions/_/departmentName[positions/_/positionTitle = xxf:instance('fr-form-instance')//control-employee-position]

I do not get the desired result. May I know what am I doing wrong here?


--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/0c59c276-3e5e-41a8-a585-98b3198b77f9%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: select parent based on child value

Alessandro  Vernet
Administrator
I notice at least 1 typo in that expression: `positions` isn't inside
`departmentName`, but inside the parent `_`. So something like this seems
"more correct":

xxf:instance('fr-dataset-staffDetails')/staff/departmentPositions/_[positions/_/positionTitle
=
xxf:instance('fr-form-instance')//control-employee-position]/departmentName

If this doesn't do it, one way to debug this is by just keeping a part of
the expression, and adding a `count(…)`, to check that at every level it
returns something (i.e. if it returns 0, you know that the expression you
have didn't return anything).

I hope this helps,

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1591223296576-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: select parent based on child value

Alessandro  Vernet
Administrator
Hi Manish,

Did you manage to make that expression work? (Also, I am noticing that the
XPath in my previous message got mangled, so let me know if you're still
working on this!)

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1592942766878-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet