Hi Everyone,
My requirement is - I am showing an Admin Form, When The user enters data in the fields, they get stored in the database and I am showing the details in a selectable grid. The user can add a row or update/remove any row by clicking on the particular row from the selectable grid which will show the data for that specific row in the form. It is working fine for text box control to fetch and show as well as be blank while entering a new data row(event).But when it comes to a dropdown(year), I am facing an issue with the below code to fetch and show the field for selected row but be blank and mapped to rule input or local variable while adding a new row, for that control. The data is not getting getting populated into a dropdown. I have added a default value "2022" to avoid the error but, I actually need "ri!HolidayDetails.year" in place of "2022". Kindly help
Thank in advance.
{ a!localVariables( /* This variable is used to persist the checkbox on selected items by holding the identifiers of the selected rows. */ local!selection, /* This variable would be used to pass the full rows of data on the selected items out of this interface, such as to a process model. */ local!selectedEvent, local!selectedRows, local!removedIds, { a!richTextDisplayField( label: "", labelPosition: "COLLAPSED", value: { a!richTextHeader(text: "Saved Holiday List") } ), a!columnsLayout( columns: { a!columnLayout( contents: { a!buttonArrayLayout( buttons: { a!buttonWidget( label: "REMOVE", saveinto: { /* Append the selected rows IDs to the local!removedIds variable. */ a!save( local!removedIds, append( local!removedIds, local!selectedEvent['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{97cb1440-dcbd-4499-b098-55caabbc20aa}id'] ) ), /* Reset local!selectedRows so other rows can be removed. */ a!save(local!selectedEvent, null), /* Reset the grid selection as well. */ a!save(local!selection, null) }, style: "NORMAL", /* Disable the button if local!selectedRows is empty. */ disabled: if( or( isnull(local!selectedEvent), length(local!selectedEvent) < 1 ), true, false ) ), a!buttonWidget( label: "Add", icon: "plus", saveInto: { a!save(ri!HolidayDetails.isactive, true()), a!save( ri!HolidayDetails.createdby, loggedInUser() ), a!save(ri!HolidayDetails.createdon, now()), a!save( ri!HolidayDetails.updatedby, loggedInUser() ), a!save(ri!HolidayDetails.updatedon, now()) }, submit: true, size: "STANDARD", style: "PRIMARY" ) }, align: "START" ), a!gridField( /* Replace the dummy data with a query, rule, or function that returns a datasubset and uses fv!pagingInfo as the paging configuration. */ data: a!recordData( recordType: 'recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar', /* This query filter applies to all rows where the row ID is found in local!removedRows. */ filters: a!queryFilter( field: 'recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{97cb1440-dcbd-4499-b098-55caabbc20aa}id', operator: if( isnull(local!removedIds), "not null", "not in" ), value: local!removedIds ) ), columns: { a!gridColumn( label: "Year", value: fv!row['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{65f69159-6237-4537-b14c-373b46496998}year'], align: "START" ), a!gridColumn( label: "Country", value: fv!row['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{253d3b95-b04e-47a3-bbaf-e89ced1eaae6}country'], align: "START" ), a!gridColumn( label: "Holiday From", value: fv!row['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{97069718-ec96-4f01-a1c5-c8ef90a5f570}fromdate'], align: "START" ), a!gridColumn( label: "Holiday To", value: fv!row['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{55a83b2d-681b-46e3-aafb-b8789e1d3f1c}todate'], align: "START" ), a!gridColumn( label: "Event", value: fv!row['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{fa36f13b-b3b8-4efd-b6f1-41bc332bdb19}event'], align: "START" ) }, pageSize: 3, selectable: true, selectionStyle: "ROW_HIGHLIGHT", selectionValue: local!selection, selectionSaveInto: { local!selection, /* This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEvent. */ a!save( local!selectedEvent, append(local!selectedEvent, fv!selectedRows) ), /* This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEvent. */ a!save( local!selectedEvent, difference(local!selectedEvent, fv!deselectedRows) ) } ) }, width: "WIDE" ), a!columnLayout( contents: { a!cardLayout( contents: { a!sideBySideLayout( items: { a!sideBySideItem( item: a!dropdownField( label: "Year", labelPosition: "ABOVE", placeholder: "--- Select a Value ---", choiceLabels: { "2021", "2022", "2023" }, choiceValues: { "2021", "2022", "2023" }, value: { if( or( isnull(local!selectedEvent), length(local!selectedEvent) = 0 ), "2022", a!forEach( local!selectedEvent, fv!item['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{65f69159-6237-4537-b14c-373b46496998}year'] ) ) }, saveInto: {}, searchDisplay: "AUTO", validations: {} ) ), a!sideBySideItem( item: a!richTextDisplayField( label: "Selected Holiday", value: { if( or( isnull(local!selectedEvent), length(local!selectedEvent) = 0 ), a!richTextItem(text: "None", style: "EMPHASIS"), a!forEach( local!selectedEvent, { a!richTextIcon(icon: "calendar-day", color: "ACCENT"), " ", a!richTextItem( text: fv!item['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{fa36f13b-b3b8-4efd-b6f1-41bc332bdb19}event'] ), char(10) } ) ) } ) ) } ), a!textField( label: "Event", labelPosition: "ABOVE", value: { if( or( isnull(local!selectedEvent), length(local!selectedEvent) = 0 ), ri!HolidayDetails.event, a!forEach( local!selectedEvent, fv!item['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{fa36f13b-b3b8-4efd-b6f1-41bc332bdb19}event'] ) ) }, saveInto: {}, refreshAfter: "UNFOCUS", validations: {} ), a!sideBySideLayout( items: { a!sideBySideItem( item: a!dateField( label: "From Date", labelPosition: "ABOVE", saveInto: {}, validations: {} ) ), a!sideBySideItem( item: a!dateField( label: "To Date", labelPosition: "ABOVE", saveInto: {}, validations: {} ) ) } ) }, height: "AUTO", style: "NONE", shape: "SEMI_ROUNDED", marginBelow: "STANDARD", showShadow: true ) } ) }, stackWhen: { "PHONE", "TABLET_PORTRAIT" } ) } ) }
Discussion posts and replies are publicly visible
I think you will have a hard time with this unless you vastly simplify what you're doing with local!selectedEvent. AFAIK this is not a valid way to populate a value for a single-value dropdown. What are you trying to do with this a!forEach() statement, exactly? As in, what is the expected behavior you're aiming for if someone has selected more than one event from the grid?
value: { if( or( isnull(local!selectedEvent), length(local!selectedEvent) = 0 ), "2022", a!forEach( local!selectedEvent, fv!item['recordType!{9d0c84f1-194c-4fbc-9e87-574eceeafad2}MOB Holiday Calendar.fields.{65f69159-6237-4537-b14c-373b46496998}year'] ) ) }
Hi Mike,
Actually I need to select only one event at a time, kindly ignore the multiselect (append). In simple words, I need a blank form at start for adding a new event, but if a user wants to update or remove the event (any 1) that should also be possible. data should be shown in the form from the grid no matter what the control type( dropdown, textbox) is. Thank you so much and sorry for the confusion.
Then can you clarify the intent behind the "a!forEach()" statement in the Value parameter of your dropdown?
Hey Mike, This code is for a sample interface I created initially, which used multiselect so the a!forEach(), I require only the field for a particular row from that record now.
I recommend you switch the grid's data source from a!recordData() over to a Query Entity rule. At present, it's difficult (to the point of being nearly impossible, IMHO) to work with 'RecordType' typed data when needing to convert individual entries back and forth to plain data, such as for editing an individual row as you're trying to do here (since your row selection will cause "local!selectedEvent" to be populated with such).