Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Binding dropdown list to XML response of web service

Avatar

Level 2

Working in Designer ES2, I am trying to populate a dropdown list with data returned by a web service, but can't seem to get the binding right. 

I created a web service using Workbench that returns the following XML data (shown here in a text field for testing purposes):

image1.PNG

However, when I bind this to the DataDropdownList control, LiveCycle seems to be trying to put the entire XML document into the dropdown list.

Binding:

image2.PNG

(Full text of the binding is connectionData.groupLeaderWebService.Body.invokeResponse.xmlData.document.)

Result:

image3.PNG

So, a connection is being made and the web service is returning data, but it is not bound correctly as items in the list. 

I need the dropdown list to display the individual names returned by the web service.  Eventually, this will probably be expanded to include name and ID number (text and value, respectively).

Can anyone see where I'm going wrong with this?  Any help would be appreciated.

Thanks!

Toby

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Whoops. Good catch. That should be pls.loadXML(form1.page1.footer.lots.rawValue,0,1);

View solution in original post

12 Replies

Avatar

Former Community Member

Toby,

This is far more complicated than most of us (any sane person) would like.You need to parse the response. I attached the SOAP message returned from a LC process. Here is the script I attached to the call to populate a drop-down.

// form1.purchaseOrder.header.invokeBtn.execEvent("click");


// loadXML() loads and appends the specificed XML document to the current object

xfa.datasets.data.loadXML(form1.purchaseOrder.header.xml_result.rawValue,0,1);


// saveXML() returns a string representing the XML fragmen of the current object

form1.purchaseOrder.header.xml_result.rawValue = xfa.datasets.data.saveXML();


var dataGroup = xfa.resolveNode("xfa.data.parts");

var dataGroupLength = dataGroup.nodes.length;


if (dataGroupLength == 0) {

  xfa.host.messageBox("There are no parts in the XML doc.");

}

else {

  for (var i=0; i < dataGroupLength; i++){

    this.addItem(dataGroup.nodes.item(i).nodes.item(0).value);

  }

}

Steve

Note. form1.purchaseOrder.header.xml_result is a hidden field.

Avatar

Level 2

Steve

Ha!  I agree.  I've really been struggling with this.  Suggestions for simplification are welcome.

My core requirement is to return a list of names (and, later, ID numbers) from a database based on user input in the form.  Basically, users are entering a department, and need a dropdown list of people in a certain position in that department. 

Users are accessing the form via Workspace.  Jasmin suggested that creating and accessing web services might be the best way to accomplish the dynamic dropdown needs.  Is there a better way to go about this?

Thanks

Toby

Avatar

Level 2

Thanks, Steve.

I'm trying to implement this.  Can you tell me what event you placed this script in?  Does it run at the client or the server?

Thanks again

Toby

Avatar

Former Community Member

Toby,

I'll get back to you in a bit with an ES2 .lca of the process and the form. The form I referenced is part of an LC 8.2.1 process and I need to import the archived process .xml to an VMWare image running LC 8.2.1 so I can export an .lca to import into ES2, if that makes any sense.

Steve

Avatar

Level 2

Steve

Frighteningly enough, that makes total sense.

Looking forward to seeing the ES2 version.  Really appreciate your help.

Thanks!

Toby

Avatar

Former Community Member

Toby,

Please send an email to stwalker.adobe@gmail.com and I will forward the assets.

Steve

Avatar

Level 2

Steve

Thanks!  After working with the example you sent me, I was able to get it to work -- great!  However, this method seems to overwrite all the other XML in my xfa:data -- not great!

For example, without the script, I have something like this in my form data variable after a form is completed and submitted:

- <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2010-08-05T15:07:02Z" uuid="62d739de-6eb3-4ae2-8cfc-4eab0dd87f17">
- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <xfa:data>
- <root>
- <performanceReview>
<badgeNumber>8107</badgeNumber>
<associateName>NATHAN JANNASCH</associateName>
<department>Information System</department>
<section>IS - System Devlopment</section>
<jobFamily>Professional Staff</jobFamily>
<GLBadge />
<groupLeader />
...
</performanceReview>
<FSTARGETURL_ />
</root>
</xfa:data>

However, when I use the script as you described above and in your sample to load the data for the dropdown list, I get this in my form data variable:

- <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2010-08-05T15:10:17Z" uuid="62d739de-6eb3-4ae2-8cfc-4eab0dd87f17">
- <xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
- <xfa:data>
- <GroupLeaders>
- <GroupLeader>
<GLBadge type="varchar">8103</GLBadge>
<GLName type="nvarchar">AARON MEISTER</GLName>
</GroupLeader>
- <GroupLeader>
<GLBadge type="varchar">5221</GLBadge>
<GLName type="nvarchar">AB EDMONDS</GLName>
</GroupLeader>
- ...
</GroupLeaders>
</xfa:data>
It looks like the data the script loads is overwriting all of my other xfa:data.  This is quite bad, as my process is dependent upon this data.  Is there a way to append the dropdownlist data to the xfa:data, or perhaps load it into another node, rather than overwriting the existing xfa:data elements?
Thanks!
Toby

Avatar

Former Community Member

Hi Toby,

The data DOM is getting stomped on. I have built forms that use multiple Web Service calls to populate multiple drop-down lists. Here is the approach I have taken to add and remove a data to/from the data DOM on-the-fly.

In this example I have a drop-down called form1.page1.section3.parkingLot that calls the script object function getParkingLots() on initialize. The function performs the following:

  • create a data node called pls
  • execute the Web Service call
  • load the XML into a hidden field called form1.page1.footer.lots
  • append the node pls to the data DOM
  • get the root node lots and assign it to a data node variable
  • iterate over the node adding the child element lot to the drop-down, and finally,
  • remove the data node pls

function getParkingLots() {

  var pls = xfa.datasets.createNode("dataGroup", "pls");

  xfa.connectionSet.GetParkingLots.execute(0);

  wb.loadXML(form1.page1.footer.lots.rawValue,0,1);

  xfa.datasets.data.nodes.append(pls);


  var dataGroup = xfa.resolveNode("xfa.data.pls.lots");

  var dataGroupLength = dataGroup.nodes.length;


  if (dataGroupLength == 0) {

    xfa.host.messageBox("There was an error retrieving parking lot data.");

  }

  else {

    for (var i=0; i < dataGroupLength; i++) {

      var lot = dataGroup.nodes.item(i).nodes.item(0).value;

      form1.page1.section3.parkingLot.addItem(lot);

    }

  }


  xfa.datasets.data.nodes.remove(pls);


}

I hope that makes sense.
Steve

Avatar

Level 2

Steve

Good stuff!  This is very helpful -- thank you.

Can you explain the "wb" in wb.loadXML(form1.page1.footer.lots.rawValue,0,1);? 

Thanks again

Toby

Avatar

Correct answer by
Former Community Member

Whoops. Good catch. That should be pls.loadXML(form1.page1.footer.lots.rawValue,0,1);

Avatar

Level 2

Ah!  Of course.

This worked great.  Thanks again for all your help with this -- I really learned a lot from it.

Toby

Avatar

Level 10

Steve,

     Can you please also forward the assets and lca to LiveCycle9@gmail.com

Thanks

Srini

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----