a!localVariables( local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 20 ), local!gridData: a!queryEntity( entity: cons!BQA_Quiz_Cons, query: a!query( pagingInfo: local!pagingInfo ), fetchTotalCount: true ), a!formLayout( label: "Example: Add,Update, or Remove Employee Data", contents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Chapter Name"), a!gridLayoutHeaderCell(label: "File Upload"), a!gridLayoutHeaderCell(label: "Description"), a!gridLayoutHeaderCell(label: "Total Questions") }, 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 ) }, rows: a!forEach( items: local!gridData, expression: a!gridRowLayout( contents: { a!textField( label: "chapterName" & fv!index, value: fv!item.chapterName, saveInto: fv!item.chapterName, required: true ), a!fileUploadField( label: "fileUpload" & fv!index, value: fv!item.fileUpload, saveInto: fv!item.fileUpload, required:true ), a!textField( label: "totalQuestion" & fv!index, value: fv!item.totalQuestion, saveInto: fv!item.totalQuestion, required:true ), a!textField( label: "description" & fv!index, value: fv!item.description, saveInto: fv!item.description, required:true ), }, id: fv!index ) ), addRowlink: a!dynamicLink( label: "Add Employee", value: { chapterName: "", fileUpload: {}, totalQuestion: "", description: "" }, saveInto: { a!save(local!gridData, append(local!gridData, save!value)) } ), rowHeader: 1 ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidget( label: "Submit", submit: true ) ) ) )
Discussion posts and replies are publicly visible
Hello balamanchari murugadas
You need to define the type! of your CDT before you define your fields,
a!dynamicLink( label: "Add Employee", value: type!CDT_NAME( chapterName: "", fileUpload: {}, totalQuestion: "", description: "" ), saveInto: { a!save( local!gridData, append(local!gridData, save!value) ) } ),
a!localVariables( local!pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 20 ), local!gridData: a!queryEntity_18r3( entity: cons!BQA_Quiz_Cons, query: a!query( pagingInfo: local!pagingInfo ), ), a!formLayout( label: "Example: Add,Update, or Remove Employee Data", contents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Chapter Name"), a!gridLayoutHeaderCell(label: "File Upload"), a!gridLayoutHeaderCell(label: "Description"), a!gridLayoutHeaderCell(label: "Total Questions") }, 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 ) }, rows: a!forEach( items: local!gridData, expression: a!gridRowLayout( contents: { a!textField( label: "chapterName" & fv!index, value: fv!item.chapterName, saveInto: fv!item.chapterName, required: true ), a!fileUploadField_17r1( label: "fileUpload" & fv!index, value: fv!item.fileUpload, saveInto: fv!item.fileUpload, required:true ), a!textField( label: "totalQuestion" & fv!index, value: fv!item.totalQuestion, saveInto: fv!item.totalQuestion, required:true ), a!textField( label: "description" & fv!index, value: fv!item.description, saveInto: fv!item.description, required:true ), }, id: fv!index ) ), addRowlink: a!dynamicLink( label: "Add Employee", value: 'type!{urn:com:appian:types:BQA}BQA_QuizApplication_DT'( chapterName: "", fileUpload: {}, totalQuestion: "", description: "" ), saveInto: { a!save( local!gridData, append(local!gridData, save!value) ) } ), rowHeader: 1 ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidget( label: "Submit", submit: true ) ) ) )
what is the type of data that is being returned from your local!gridData ?
Data subset
I meant what is the Entity
a!queryEntity_18r3( entity: cons!BQA_Quiz_Cons, query: a!query( pagingInfo: local!pagingInfo ), )
Does the constant refer to the entity of type you have mentioned? BQA_QuizApplication_DT?
Yes
Stefan Helzle said:you query data and local!gridData contains data of type datasubset. Then, in your "Add Row" link, you try to append a CDT type item to that datasubset.
This is your error. Index only data from your query and cast it to your CDT
Can you explain deeply i not got
Something in the line with this.
local!gridData: cast( a!listType(type!YOUR_CDT), a!queryEntity( entity: cons!BQA_Quiz_Cons, query: a!query( pagingInfo: local!pagingInfo ), fetchTotalCount: true ).data, )
Now, your local gridData keeps a consistent data type and the append will not break it.
What you did is, in that local, you stored a datasubset return by the query. Then you turned that into a list by appending a CDT type item. Now that local contains two items, a datasubset and a CDT item. Now, the foreach tries to iterate in these items what break the field references inside the rowlayout fields.
Hi,
I have created like u said but i am getting error did i have to use record type for this
When you Query the output comes in as "DataSubset". Same thing is happening in your case .Type of local!griddata is "DATASUBSET". And when you are trying to add another row, save!Value is of your CDT type. It leads to Casting error
I Just observed it in your grid is it showing the right data?? and when you try to update, is it happening properly without any errors?? I mean your index needs to look like this fv!item.data.chaptername .
As you are using queryEntity, you need to use CDT types.
But your mistake is, that you create an item instead of referencing the data type in line 7. Remove the emphasis after the type.
I got it now. Thank you for your guidance