Hello Everyone,
Can anyone help me with this error, please?
Interface Definition: Expression evaluation error: An error occurred while executing a save: Expression evaluation error at function 'wherecontains' [line 69]: Invalid types, can only act on data of the same type (Any Type, Number (Integer))
Please find the code below.
load(local!removeFailure: false,local!removedIDs: {},local!gridSelection: a!gridSelection(pagingInfo: a!pagingInfo(startIndex: 1,batchSize: 10,sort: a!sortInfo(field: "id",ascending: true))),local!employeeData:a!queryEntity(entity:cons!Employee_S_datastoreConstant,query:a!query(selection:a!querySelection(columns:{a!queryColumn(field:"id"),a!queryColumn(field:"firstname"),a!queryColumn(field:"lastname")} ),pagingInfo:local!gridselection.pagingInfo)),/* Set the default paging and sorting config `*/ with(/* Replace the value of local!employeeData with `a!queryEntity()`, or *//* `queryrecord()`, or use your own CDT array in todatasubset() */ a!formLayout(label: "Example: Delete from Grid",contents:{a!buttonLayout(secondaryButtons: {a!buttonWidget(label: "Remove",value: true,saveInto: {if(or(isnull(local!gridSelection.selected),length(local!gridSelection.selected)<1),local!removeFailure,{}),a!save(local!employeeData, remove(local!employeeData, wherecontains(local!gridSelection.selected, tointeger(index(local!employeeData,"id",null))))),if(local!removeFailure,{},a!save(local!removedIDs, append(local!removedIDs, local!gridSelection.selected))),/*` This sets the start index back by one page when ** all of the results on the final page are deleted. */a!save(local!gridSelection.pagingInfo.startIndex,if(local!gridSelection.pagingInfo.startIndex <= length(local!employeeData),/* If at least as many items as the previous start index exist, use it `*/local!gridSelection.pagingInfo.startIndex,/* Otherwise, create a new start index to avoid an error */if(length(local!employeeData)<=local!gridSelection.pagingInfo.batchSize,/* If the last item in the grid was deleted or there are only enough items for one page, use 1 */1,/*` If there are multiple pages' worth remaining, adjust the start index so that the last page *//* of items is shown */(length(local!employeeData)+1)-local!gridSelection.pagingInfo.batchSize))),a!save(local!gridSelection.selected, null)})}),a!gridField(instructions: if(local!removeFailure, "Select one or more items to remove.", ""),totalCount: local!employeeData.totalCount,columns: {a!gridTextColumn(label: "First", field: "firstname", data: index(local!employeeData.data, "firstname" , {})),a!gridTextColumn(label: "Last", field: "lastname", data: index(local!employeeData.data, "lastname" , {})), },identifiers: index(local!employeeData.data, "id" , {}),value: local!gridSelection,saveInto: {local!gridSelection,a!save(local!removeFailure,if(or(isnull(local!gridSelection.selected), length(local!gridSelection.selected) < 1),local!removeFailure,false))},selection: true), },buttons: a!buttonLayout(primaryButtons: a!buttonWidget(label: "Submit",submit: true)))))
Discussion posts and replies are publicly visible
Hi Sandeep,
Please modify the Code as mentioned
load( local!removeFailure: false, local!removedIDs: {}, local!gridSelection: a!gridSelection( pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10, sort: a!sortInfo( field: "id", ascending: true ) ) ), local!employeeData: a!queryEntity( entity: cons!Employee_S_datastoreConstant, query: a!query( selection: a!querySelection( columns: { a!queryColumn( field: "id" ), a!queryColumn( field: "firstname" ), a!queryColumn( field: "lastname" ) } ), pagingInfo: local!gridselection.pagingInfo ) ), /* Set the default paging and sorting config `*/ with( /* Replace the value of local!employeeData with `a!queryEntity()`, or */ /* `queryrecord()`, or use your own CDT array in todatasubset() */ a!formLayout( label: "Example: Delete from Grid", contents: { a!buttonLayout( secondaryButtons: { a!buttonWidget( label: "Remove", value: true, saveInto: { if( or( isnull( local!gridSelection.selected ), length( local!gridSelection.selected ) < 1 ), local!removeFailure, {} ), a!save( local!employeeData.data, remove( local!employeeData.data, /*wherecontains( local!gridSelection.selected, tointeger( index( local!employeeData.data, "id", null ) ) )*/ wherecontains( tointeger( index( local!gridSelection, "selected", {} ) ), tointeger( index( local!employeeData.data, "id", null() ) ) ) ) ), if( local!removeFailure, {}, a!save( local!removedIDs, append( local!removedIDs, local!gridSelection.selected ) ) ), /*` This sets the start index back by one page when * * all of the results on the final page are deleted. */ a!save( local!gridSelection.pagingInfo.startIndex, if( local!gridSelection.pagingInfo.startIndex <= length( local!employeeData.data ), /* If at least as many items as the previous start index exist, use it `*/ local!gridSelection.pagingInfo.startIndex, /* Otherwise, create a new start index to avoid an error */ if( length( local!employeeData.data ) <= local!gridSelection.pagingInfo.batchSize, /* If the last item in the grid was deleted or there are only enough items for one page, use 1 */ 1, /*` If there are multiple pages' worth remaining, adjust the start index so that the last page */ /* of items is shown */ ( length( local!employeeData.data ) + 1 ) - local!gridSelection.pagingInfo.batchSize ) ) ), a!save( local!gridSelection.selected, null ) } ) } ), a!gridField( instructions: if( local!removeFailure, "Select one or more items to remove.", "" ), totalCount: local!employeeData.totalCount, columns: { a!gridTextColumn( label: "First", field: "firstname", data: index( local!employeeData.data, "firstname", {} ) ), a!gridTextColumn( label: "Last", field: "lastname", data: index( local!employeeData.data, "lastname", {} ) ), }, identifiers: index( local!employeeData.data, "id", {} ), value: local!gridSelection, saveInto: { local!gridSelection, a!save( local!removeFailure, if( or( isnull( local!gridSelection.selected ), length( local!gridSelection.selected ) < 1 ), local!removeFailure, false ) ) }, selection: true ), }, buttons: a!buttonLayout( primaryButtons: a!buttonWidget( label: "Submit", submit: true ) ) ) ) )
Thanks,
Farnaz
Please check this code
load(local!removeFailure: false,local!removedIDs: {},local!gridSelection: a!gridSelection(pagingInfo: a!pagingInfo(startIndex: 1,batchSize: 10,sort: a!sortInfo(field: "id",ascending: true))),
local!employeeData:todatasubset( {}, local!gridSelection.pagingInfo),/* Set the default paging and sorting config `*/
with(/* Replace the value of local!employeeData with `a!queryEntity()`, or *//* `queryrecord()`, or use your own CDT array in todatasubset() */
a!formLayout(label: "Example: Delete from Grid",contents:{ a!buttonLayout(secondaryButtons: {a!buttonWidget(label: "Remove",value: true,saveInto: {if(or(isnull(local!gridSelection.selected),length(local!gridSelection.selected)<1),local!removeFailure,{}),a!save(local!employeeData.data, remove(local!employeeData.data, wherecontains(tointeger(index(local!gridSelection,"selected",{})), tointeger(index(local!employeeData.data,"id",null))))),if(local!removeFailure,{},a!save(local!removedIDs, append(local!removedIDs, local!gridSelection.selected))),/*` This sets the start index back by one page when ** all of the results on the final page are deleted. */a!save(local!gridSelection.pagingInfo.startIndex,if(local!gridSelection.pagingInfo.startIndex <= length(local!employeeData),/* If at least as many items as the previous start index exist, use it `*/local!gridSelection.pagingInfo.startIndex,/* Otherwise, create a new start index to avoid an error */if(length(local!employeeData.data)<=local!gridSelection.pagingInfo.batchSize,/* If the last item in the grid was deleted or there are only enough items for one page, use 1 */1,/*` If there are multiple pages' worth remaining, adjust the start index so that the last page *//* of items is shown */(length(local!employeeData.data)+1)-local!gridSelection.pagingInfo.batchSize))),a!save(local!gridSelection.selected, null)})}),a!gridField(instructions: if(local!removeFailure, "Select one or more items to remove.", ""),totalCount: local!employeeData.totalCount,columns: {a!gridTextColumn( label: "First", field: "firstname", data: index( local!employeeData.data, "firstname", {} ) ),a!gridTextColumn(label: "Last", field: "lastname", data: index(local!employeeData.data, "lastname" , {})),
},identifiers: index(local!employeeData.data, "id" , {}),value: local!gridSelection,saveInto: {local!gridSelection,a!save(local!removeFailure,if(or(isnull(local!gridSelection.selected), length(local!gridSelection.selected) < 1),local!removeFailure,false))},selection: true),
},buttons: a!buttonLayout(primaryButtons: a!buttonWidget(label: "Submit",submit: true)))))