cancel
Showing results for 
Search instead for 
Did you mean: 

Populate Unity Form Drop Down via Unity API

Marcus_Christi2
Elite Collaborator
Elite Collaborator

The question isn't (quite) what you think.

Have a Unity Form.  Has a dropdown based on a keyword. 

I wrote a script against IExternalKeywordDataSetScript and it works fine.  But I noticed in Diagnostics it's making two trips, one for each time the user clicks the element.  So it's retrieving the full recordset again after the user selects what they want rather than just the first request.

Funny thing: this only happens on Unity Forms.  It does NOT happen on a direct Import.  So it's definitely something with how Unity Forms executes the External Data Set.

My question: is there some other method that would allow me to populate this dataset without the extra trip against the app server that I'm just not seeing?  I saw the Custom Action method, but that appears to be only for fields. 

1 ACCEPTED ANSWER

Marcus_Christi2
Elite Collaborator
Elite Collaborator

After some additional testing, what I want isn't there. 

The issue is really with Unity Forms' interface.  They're making the call to get the dataset when the user clicks - which is fine.  But they're not trapping first whether or not that event has already happened so that they can avoid doing the same call a second time needlessly.

In pseudo code:

  • Set a boolean of "NO" for eventStatus on the form load.
  • When the user clicks the element, test whether eventStatus = NO.
  • If eventStatus = NO, get the Keyword Data Set and set eventStatus = YES.  Cache the data to the user's session.
  • If eventStatus = YES, don't do anything.  They already have the data.

This is basically how the regular Import is doing it since it's not making the second call.  However that code is written, that should also apply to the Unity Form interface itself, ideally.  

I can't script around it because it does need to be a Keyword Data Set, but by making it a Keyword Data Set, it means Unity Forms will always do the same execute when the user clicks it.

The other option would be to add a Custom Action to "Get Data Set From a Script" or something.  That way I can throw a condition against it to prevent it from multiple hits.

As a side note, E-Forms does not have this issue because when you set a field as OBDataset, it's pulling back whatever dataset at form load.  Slows it down a bit but doesn't need to do multiple calls.  Another W in the column there.

View answer in original post

4 REPLIES 4

Tyler_Sorber
Star Collaborator
Star Collaborator

Hi Marcus

In order to populate a Dataset like you are, an IExternalDatasetScript is the correct process.  As for multiple trips to the AppServer, this may be something that is better handled by your first line of support. 

I would suggest having a few things ready for them to help speed up the troubleshooting process, before contacting support.  They will want you to be able to replicate the issue with a very basic script; possibly with hardcoded values.  Additionallity, the Service, Web.Service, and Database Tabs of Diagnostics should be provided as an XML Snapshot of all Tabs.

John_Webber1
Champ in-the-making
Champ in-the-making

You could try fiddling with the "Filter Select List" custom action in the Unity client which I believe is one trip to the app server after selecting from the first select box.

There's only one select box. That's the problem.

If I had to describe what I'm seeing, it's like the Unity Form is executing its own version of "OnClick" to get the keyset data - basically, just clicking on the element runs the call to get the keyset, which runs the script. The problem with that is that you must click the element twice: once to display the list, one to select the item.

This isn't how Import works. There, it's only executing at the time of the list population, not the selection of the element. IMO that should really be fixed. The form should only execute the dataset pull ONE time. There's no need to re-execute a dataset that hasn't changed after the user has pulled the list.

Marcus_Christi2
Elite Collaborator
Elite Collaborator

After some additional testing, what I want isn't there. 

The issue is really with Unity Forms' interface.  They're making the call to get the dataset when the user clicks - which is fine.  But they're not trapping first whether or not that event has already happened so that they can avoid doing the same call a second time needlessly.

In pseudo code:

  • Set a boolean of "NO" for eventStatus on the form load.
  • When the user clicks the element, test whether eventStatus = NO.
  • If eventStatus = NO, get the Keyword Data Set and set eventStatus = YES.  Cache the data to the user's session.
  • If eventStatus = YES, don't do anything.  They already have the data.

This is basically how the regular Import is doing it since it's not making the second call.  However that code is written, that should also apply to the Unity Form interface itself, ideally.  

I can't script around it because it does need to be a Keyword Data Set, but by making it a Keyword Data Set, it means Unity Forms will always do the same execute when the user clicks it.

The other option would be to add a Custom Action to "Get Data Set From a Script" or something.  That way I can throw a condition against it to prevent it from multiple hits.

As a side note, E-Forms does not have this issue because when you set a field as OBDataset, it's pulling back whatever dataset at form load.  Slows it down a bit but doesn't need to do multiple calls.  Another W in the column there.