Hi all ,
I have the requirement ,
When user types in the field , it shows down the list as suggestion but it also allows to save what is not in list . (Eg: when "a" is typed : --> {"apple","aeroplane","awesome"} is suggested . But when user types "akward" ,which is not in list . It is still able to save this word in local variable.I refered to (https://docs.appian.com/suite/help/19.4/recipe-configure-an-array-picker.html) .But when I typed, whats not in list , it says "No search found" and doesn;t allow me to save what I typed.ANY HELP ?Kind Regards
Discussion posts and replies are publicly visible
Hi. I implemented exactly this a few years ago. The trick is in the suggest function. If the user enters a value which is not known, I just add the search value to the returned data sub set. See below code.
=if( isnull(ri!search), todatasubset({}), with( local!types: a!queryEntity_18r3( entity: cons!EIF_ENTITY_TAGS, query: a!query( filter: a!queryFilter( field: "search", operator: "includes", value: lower(ri!search) ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10, sort: a!sortInfo( field: "name", asending: true ) ) ) ), if( local!types.totalCount > 0, a!dataSubset( startIndex: 1, batchSize: 10, totalCount: local!types.totalCount, data: index(local!types.data, "name", {}), identifiers: local!types.identifiers ), a!dataSubset( startIndex: 1, batchSize: 1, totalCount: 1, data: ri!search, identifiers: ri!search ) ) ) )
Create an expression rule with the below code snippet and call this rule in your SUGGEST FUNCTION:
Expression Rule inputs:
choiceList: text(multiple)
searchValue: text
Code:
if( contains(ri!choiceList,ri!searchText), a!dataSubset( startIndex: 1, batchSize: -1, totalCount: count(ri!choiceList), data: ri!choiceList, identifiers: ri!choiceList ), a!dataSubset( startIndex: 1, batchSize: 1, totalCount: 1, data: ri!searchText, identifiers: ri!searchText ))
Hi Stefan,
I tried changing the suggest function as you mentioned. But I am getting error - Suggest function is unavailable.
=if( isnull(ri!search), todatasubset({}), with( local!types: a!queryEntity( entity: ri!entity, query: a!query( filter: a!queryFilter( field: ri!fieldName, operator: "includes", value: lower(ri!search) ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10, sort: a!sortInfo( field: ri!fieldName, asending: true ) ) ) ), if( local!types.totalCount > 0, a!dataSubset( startIndex: 1, batchSize: 10, totalCount: local!types.totalCount, data: index(local!types.data, ri!fieldName, {}), identifiers: local!types.identifiers ), a!dataSubset( startIndex: 1, batchSize: 1, totalCount: 1, data: ri!search, identifiers: ri!search ) ) ) )
Could you please let me know, if anything is missing?
Thank you
What is the code of your picker?
Below is the code :
a!pickerFieldCustom( label: "Product", labelPosition: "ABOVE", maxSelections: 1, suggestFunction: rule!CDS_RULE_ucArrayPickerFilter( entity: cons!CDS_ENTITY_PRODUCT, search: fv!item.name, fieldName: "reviewName" ), selectedLabels: a!forEach( items: fv!item.name, expression: fv!item ), placeholder: "Type to see existing products", value: fv!item.name, saveInto: { fv!item.name, a!save( ri!lppcProduct[fv!index].name, save!value ) }
Getting error at custom picker - TExpression evaluation error at function a!pickerFieldCustom [line 35]: The function 'suggestfunction' is unavailable.
Line 7 is wrong. Check
docs.appian.com/.../recipe-configure-an-array-picker.html
Do you mean to keep in the below format?
suggestFunction: rule!CDS_RULE_ucArrayPickerFilter( search: _, entity: cons!CDS_ENTITY_PRODUCT, fieldName: "reviewName" ),
In this case, I am not getting any suggestions for existing values
This is correct. Now this is a partially evaluated reference to you suggestion rule. The "_" is doing that. At runtime, the "_" will be replaced be the text entered by the user.
https://docs.appian.com/suite/help/20.3/Expressions.html#parallel-evaluation-of-expressions
I do not know why your expression does not return values. Test it in isolation.
Got the issue, In your suggested function , fetchTotalCount is not set but checking the condition based on total count.
So, It works fine now with the below code :
=if( isnull(ri!search), todatasubset({}), with( local!types: a!queryEntity( fetchTotalCount: true(), entity: ri!entity, query: a!query( filter: a!queryFilter( field: ri!fieldName, operator: "includes", value: lower(ri!search) ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10, sort: a!sortInfo( field: ri!fieldName, asending: true ) ) ) ), if( local!types.totalCount > 0, a!dataSubset( startIndex: 1, batchSize: 10, totalCount: local!types.totalCount, data: index(local!types.data, ri!fieldName, {}), identifiers: local!types.identifiers ), a!dataSubset( startIndex: 1, batchSize: 1, totalCount: 1, data: ri!search, identifiers: ri!search ) ) ) )