My scenario is to create an editable grid which takes user data and simply save into the database but the catch is the column data in the grid is from multiple different CDTs or tables.
For example : Two columns "Quantity" and "Price" are from one CDT table called "Request"
Another one column "Comment" is from table "Comment" and there is "RequestType" from reference table "RequestTypeRef" which can have any of the two values "Supply" or "Service" and lastly "Item" which is dependent on "Request Type", if it is "Supply" then "Item" should save in "SupplyTypeName" of "SupplyTypeRef", else in "ServiceTypeRef".
Below is the code I've written and for now taking rule inputs as request, requestTypeRef, serviceTypeRef, supplyTypeRef and comment, all are array of these datatypes because user can make multiple requests (not more than 5) at a time.
For better understanding, attaching the screenshot of what I've developed so far.
a!localVariables( a!formLayout( label: "Create New Request", instructions: "Create a new Request Type, maximum 5 requests can be created at a time", contents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell( label: "Request Type" ), a!gridLayoutHeaderCell( label: "Item", helpTooltip: "Enter the Item Name to request" ), a!gridLayoutHeaderCell( label: "Quantity" ), a!gridLayoutHeaderCell( label: "Price ($)" ), a!gridLayoutHeaderCell( label: "Comment" )/*,*/ /*a!gridLayoutHeaderCell(*/ /*label: ""*/ /*)*/ }, columnConfigs: { a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 3 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 3 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 3 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 3 ), a!gridLayoutColumnConfig( width: "DISTRIBUTE", weight: 3 ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: a!gridRowLayout( contents: { a!dropdownField( label: "request type", placeholderLabel: "-- Please Select-- ", choiceLabels: cons!OSR_TEXT_ARRAY_REQUEST_TYPE, choiceValues: cons!OSR_TEXT_ARRAY_REQUEST_TYPE, value: index( ri!requestTypeRef, "RequestTypeName", {} ), saveInto: ri!requestTypeRef.RequestTypeName, required: true ), a!textField( label: "item", value: if( ri!requestTypeRef.RequestTypeName = "Service", index( ri!serviceTypeRef, "ServiceTypeName", {} ), index( ri!supplyTypeRef, "SupplyTypeName", {} ) ), saveInto: if( ri!requestTypeRef.RequestTypeName = "Service", ri!serviceTypeRef.ServiceTypeName, ri!supplyTypeRef.SupplyTypeName ), required: true ), a!integerField( label: "quantity", value: index( ri!request, "Quantity", {} ), saveInto: ri!request.Quantity, required: true ), a!textField( label: "price", value: todecimal( index( ri!request, "Price", {} ) ), saveInto: ri!request.Price, required: true ), a!paragraphField( label: "comment", value: index( ri!comment, "Comment", {} ), saveInto: ri!comment.Comment ) } ), rowHeader: 1 ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: cons!OSR_TEXT_BUTTON_SUBMIT, submit: true, style: "PRIMARY" ) }, secondaryButtons: { a!buttonWidget( label: cons!OSR_TEXT_BUTTON_CANCEL, value: true, saveInto: ri!cancel, submit: true, style: "NORMAL", validate: false ) } ) ) )
Discussion posts and replies are publicly visible
In that case, you should probably modify your Supply Type and Service Type CDTs to include a Request Type ID, so that they can be tied together in the database and in your editable grid in a meaningful way. Otherwise it will be difficult to nearly imossible to meaningfully tie a new entry of either to the appropriate row in your grid, for starters.
True. I'll definitely check on that. Thanks for the suggestion again...