Client Script to either validate data on a Record Producer on submit or Update a Field to correct it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 11:20 AM
I am trying to find a way to eliminate a data entry error on a Record Producer that is part of our Onboarding process.
Use Case:
- In our Onboarding process for International Hires we collect the person's Home Country address at the beginning of the process.
- When they arrive here in the US orCAN they have an Onboarding task to update the original address we have in the system to their new local address. In the system, the person opens a Record Producer that displays their original Home Country address and allows them to update it with their new Local Address information.
The Problem:
For some reason people are not updating the Home Address Country field. (Example: They are moving from France to the United States. When they update their address in the system they are leaving the Country as "France" instead of updating it. This is causing downstream issues.)
The Solution - this is what I need help implementing
- Option 1: A catalog client script that updates the Home Address Country field to match the Work Address Country when the update address record producer is submitted. Unfortunately I have had no luck finding any examples of a script that does this sort of update on submit. I don't write code so I usually hunt for something existing that does what I need a new script to do and then copy and swap out field names. No luck with that approach here. Pretty much everything I've found/read about is "OnUpdate" which doesn't apply here since the whole problem is the field is not being updated
- Option 2: (This is a poor substitute for Option 1 but would be better than nothing.) I thought I could devise some sort of data validation popup which would prompt the user to update their Home Address Country if it was not either US or CAN. I found an existing script in my instance that does something like this but I am not able to figure out how to identify/reference the person's Work Location Country in a script. I know it is User->Location->Country but how do I say that in the catalog client script so SN knows what field I'm referring to?
Any help or advice will be appreciated.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 09:36 AM
If 'country' is the correct variable name for work country (even when mapping a variable to a field in a Record Producer, the Name of the variable can be changed) then this is likely a timing issue - you are trying to set the value or clear it before it has a value. If you already have an onLoad Catalog Client script that is populating the 'country' variable (among others) add the line from the new script to that other script right after 'country' is populated - and you can use whatever that line is using to populate 'country' to also populate 'u_home_address_country' rather than g_form.getValue... You can always add alert lines to confirm the variable names and existing values are correct, and what you expect:
alert('Work Country = ' + g_form.getValue('country'));
alert('Home Country = ' + g_form.getValue('u_home_address_country'));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 10:00 AM
Hi Brad
There is an existing onLoad script that populates the fields so this makes sense. I will give it a try. (I won't be able to do that for a bit as I am traveling but I will circle back once I do. Thank you again for your help!
Irene