Expand my Community achievements bar.

Using XML Datasource - is this possible

Avatar

Level 1

Firstly, let me say I have searched the web, this forum and the tutorials etc to find something useful to point me in the right direction but had no luck thus far.

I have some XML that looks like this;

<StaffList>
    <Staff StaffId="1" Name="Fred Nerk" Mission="JMO">
        <SAC Code="001001"/>
        <SAC Code="001002"/>
        <SAC Code="001003"/>
    </Staff>
    <Staff StaffId="2" Name="John Doe" Mission="UKDEL">
        <SAC Code="001002"/>
    </Staff>
    <Staff StaffId="3" Name="Jane Citizen" Mission="UKREP">

        <SAC Code="001002"/>

    </Staff>
    <Staff StaffId="4" Name="Kim Hughes" Mission="JMO">

        <SAC Code="001002"/>

    </Staff>
</StaffList>

We have a dropdown list that contains the Name attribute of each staff element.  We have done that by using a Datasource and binding it to the XML.  Easy.

Once a Staff member is selected in the dropdown list we would like to populate a control with the value of the "Code" attribute from the child SAC Code element(s) for the selected Staff member.  We would also like to populate a control with the "Mission" attribute for the selected Staff element.

Is this possible using LC designer?  If so what tactic can we use to do it?  Any help appreciated.  Happy to reshape the XML if it makes it easier.

4 Replies

Avatar

Former Community Member

It can be done but it will involve code ...are you OK with that?

Paul

Avatar

Level 10

Hi,

I also think you will need some code but it wont be a lot.  In the change event of you dropdown list you will need something like;

var

staffDataNode = $record.resolveNode("StaffList.Staff.(StaffId.value == " + this.boundItem(xfa.event.change) + ")" );

SAC.clearItems();

for

(var i=0; i<staffDataNode.SAC.all.length; i++ )

{

     SAC.addItem(staffDataNode.SAC.all.item(i).Code.value);

}

Mission.rawValue

= staffDataNode.Mission.value;

where SAC and Mission are the controls for the dependent values

Attached is my form to test the above code.

Bruce

Avatar

Level 1

Thanks for the replies guys.  Will give this a go early next week, but at least I know it is doable and now have somewhere to start.


Avatar

Level 1

Thanks BR001, champion work.  What have you done is bang on the money and I am now cooking with gas.

<quote>

pguerett

It can be done but it will involve code ...are you OK with that?

Paul </ quote>

I am OK (but am definitely not a rocket scientist) with script to this level, but I do prefer 4GL with real debuggers etc...