Hi ,
I am checking name field in table TestDataSetIdByName . As per my requirement if entered name is already exists in table then it should display one error message.
But issue is we have requirement like already we have junk data which we can't remove but we need to add new validation for adding any new name. If that is available then this validation should work.
Suppose i am entering name is "Appian" which is already in table 3 times , then this validation rule is displaying error message three times which is not expected , it should display only one time.
What is work around for that. PFA code also.
load( local!name, local!selectedButton, a!formLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!sectionLayout( contents: { a!columnsLayout( columns: { a!columnLayout( contents: { a!textField( label: "Name", required: true(), labelPosition: "ADJACENT", value: ri!TestDataSet.name, saveInto: ri!TestDataSet.name ), } ) } ) } ) } ) } ) }, validations: { if( and( local!selectedButton = "add", local!name <> ri!TestDataSet.name ), if( tointeger( rule!TestDataSetIdByName( ri!TestDataSet.name ) ) >= 1, a!validationMessage( message: "This name already exists, please enter a different name.", validateAfter: "REFRESH" ), {} ), {} ) } ) )
Please ignore unnecessary syntax as i have to filter rest of company code .
Discussion posts and replies are publicly visible
Suggested Solutions :-
1) Use paging where you are querying data from DB and set batch size as 1,
2) Do union(local!name,local!name) if the fetched names from DB are coming in that variable.
So in general we are removing duplicates from variable as you are just using it for validation. you can use one of the above solution (1 is preferable )
please ignore local!name as that i have added for some other validation.
Option 1 you suggested, can add that code as i didn't get this.
Yes you can use Paging with batch size as 1.
But how you will put paging info to validation message,
As per your requirement " As per my requirement if entered name is already exists in table then it should display one error message."
This suggests you are querying from DB to check if name already exists. use Paging while you query and put batch size as 1.
I guess this is the rule where paging is needed
rule!TestDataSetIdByName( ri!TestDataSet.name )
Thanks a lot Mudit. Now it got resolved.