Amongst all the bug fixes and features added since my last post, in the 1.0.39 release of Aikau we've added a useful addition to our forms capabilities that I thought would be worth calling out. It's actually something that I've been meaning to add for a while but have never had a use-case to drive its inclusion. If you're not familiar with the different ways in which you can provide a from control with options, then you should review the information in this tutorial before reading any further.
When using a form control (e.g. Select, ComboBox, MultiSelectInput, RadioButtons), you can provide a “publishTopic” attribute that will be used to request the options for that form control to use, however the published payload didn't provide any data about the the current values of the other fields in the form. We've now updated the Form widget to subscribe to a new topic that can be used to update the options-requesting payload with the current form values and then forward the request onto another topic.
In the specific use-case we needed to solve, we needed to get the available sites on the currently selected Cloud network. When the user changed the network we wanted to update a FilteringSelect widget to show the sites for that network.
This extract from one of our form models shows how this can be configured
{
id: 'CLOUD_SYNC_TENANT',
name: 'alfresco/forms/controls/FilteringSelect',
config: {
fieldId: 'CLOUD_SYNC_TENANT',
name: 'remoteTenantId',
label: 'cloud-sync.dialog.network.label',
optionsConfig: {
queryAttribute: 'value',
labelAttribute: 'value',
valueAttribute: 'value',
publishTopic: topics.GET_CLOUD_TENANTS,
publishPayload: {
resultsProperty: 'response'
}
}
}
},
{
id: 'CLOUD_SYNC_SITE',
name: 'alfresco/forms/controls/FilteringSelect',
config: {
fieldId: 'CLOUD_SYNC_SITE',
name: 'remoteSiteId',
label: 'cloud-sync.dialog.site.label',
optionsConfig: {
changesTo: [
{
targetId: 'CLOUD_SYNC_TENANT'
}
],
queryAttribute: 'title',
labelAttribute: 'title',
valueAttribute: 'shortName',
publishTopic: topics.GET_FORM_VALUE_DEPENDENT_OPTIONS,
publishPayload: {
publishTopic: topics.GET_CLOUD_SITES,
resultsProperty: 'response'
},
publishGlobal: false
}
}
},
The key things to notice here are:
In this example the options retrieval is handled by a service subscribing to the topics.GET_CLOUD_SITES. This is able to check the published payload to find the tenant from which to retrieve the sites, e.g:
if (payload.username && payload.remoteTenantId)
{
this.serviceXhr({
url : AlfConstants.PROXY_URI + 'cloud/people/' + payload.username + '/sites?network=' + payload.remoteTenantId,
method: 'GET',
data: payload
});
}
This is obviously just a single example of how this feature could be used. No doubt there will be plenty of other use cases in the future that need to take advantage of this capability.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.