Good Afternoon,
@Pulkit_Jain_ this is the form you just helped me with. I'm hoping you or someone can help me as this request is a little more complicated. I need to run a script that will check for duplicates within the employeeName field but this table has a repeating row AND the entire table is running an add and instance script. A pop up window will work or even highlighting the duplicated names would work.
Please see the form here:
https://drive.google.com/file/d/1oVWCDknyCNWwImMSOHKK0990-1O7ITzB/view?usp=sharing
Thank you,
Emilee
Solved! Go to Solution.
Views
Replies
Total Likes
I got it working. Please see below and confirm that's what you wanted. Duplicates are highlighted in all the tables on button click.
Update Form: https://drive.google.com/file/d/1RQhNjPKf28AjUuNbPmnv73ZrZU-N-8jq/view?usp=sharing
I see that there could be multiple rows/employee names in a table and multiple tables (with "Add payroll information")
What event do you want to check the duplicate values with? I don't see any submit button or option to save the form. We can check for the duplicate names but wanted to understand the use-case better.
@Pulkit_Jain_ The idea is that the users/customers would submit the form but the user wouldnt really be the ones looking at the duplicates, it would be our employees who would look for duplicates. If we had to create a button for our people to click to find them easily that would work. What do you suggest?
I have fixed your form with the script below, being executed on employeeName column's Exit event. Please check it out!
var rows = this.resolveNodes("tbleEmployeeInfo.repeatingRow[*]"); var dup = false; for (var i = 0; i < rows.length; i++) { for (var j = 0; j < rows.length; j++) { if (i != j) { if (rows.item(i).employeeName.rawValue == rows.item(j).employeeName.rawValue) { dup = true; break; } } } } if(dup) xfa.host.messageBox("Duplicate Found");
Fixed form: https://drive.google.com/file/d/1RQhNjPKf28AjUuNbPmnv73ZrZU-N-8jq/view?usp=sharing
This seems to check only within a table, I would need to have it check the whole form once it is filled out. The other thing is that it doesnt need to happen while filling out as duplicates are ok and I dont want to alarm our customers. Our employees take that filled out form and search for the duplicates and might need to make an adjustment. The way this is, it seems like it creates an error window only within the one table at a time. Maybe a button really is the better way to go? I will spend more time tomorrow. Sorry I work for the state and cant stay later.
You may add a Validate button on the form, and add the same script on the click event of the button for all the tables in the form. The logic would be same.
@Mayank_Tiwari I was able to create a validate button at the bottom of the form and get it to work the same as your original idea. The issue is that it still only indicates duplicates within the original table. For example, if I put a value in the first employeeName field then click on the "Add Payroll Information" button then put the same value in the new employeeName field, it does not catch duplicates in both tables this script (the way I have it) only works on the very first table. Is there a way to check for duplicates for infinity add instances of subPayRollInfo? Also, now that I've seen this run I realized that just indicating there is a duplicate will not really help as we will still have to hunt for them(this form could get lengthy). Can we highlight all the duplicates instead? Is that possible?
https://drive.google.com/drive/folders/1gNJSIUYdh-i-sR07mlwzOsl1Fv2jp-s4?usp=sharing
You need to merge the repeatingRow array from each of the subPayRollInfo instance into a single array, by using a loop. And then apply the same logic on the merged array to find the duplicates.
Please forgive me, I just cant get this to work. Can you look at my document and see where I'm going wrong? I need to specify where the duplicates are and highlight them somehow when the button is clicked. I've tried a few things but I still cant get the script to check any table but the first one. Thank you again for your help.
I got it working. Please see below and confirm that's what you wanted. Duplicates are highlighted in all the tables on button click.
Update Form: https://drive.google.com/file/d/1RQhNjPKf28AjUuNbPmnv73ZrZU-N-8jq/view?usp=sharing
Thats it! I thank you from the bottom of my heart!!! I'm learning everyday and you guys are a big part of it.
Views
Likes
Replies
Views
Likes
Replies