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-26-2023 12:50 PM
Since you don't write code you definitely don't want to start with trying Server Side actions in a Client Script (GlideAjax). Instead I suggest option 3. Create a Flow that runs (triggered) when the Record Producer creates (inserts) the record. You can easily look up records with simple conditions and dotwalk to all the data and references on the records and the trigger record....I just looked at your screenshot...you could also do a onChange Client Script that runs on the "Country" field and updates "Work Country".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 08:15 AM
Hi Tera
Thank you so much for trying to help me. I did invest some time on trying to get an OnChange client script to work. Nothing worked. I was guessing that was because the field value was not actually changing.
I don't have any experience with Flow Designer but will definitely take a look to see if I can figure out how to leverage it to solve this problem. So thanks also for that suggestion. It sounds like it might be a good tool for me. My frustration with SN about how difficult it is to do simple things like this cannot be overstate. It eats up a stupid amount of my time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 12:58 PM
I would recommend an onLoad script that either clears the Home Address Country, and other address-related variables, or updates the Country to match the Work Address Country if that's what you really want, but the point is it is presented on the Record Producer to the user, not overwriting data they may have updated. In any event, a script to do so would simply be:
function onLoad() {
g_form.clearValue('var_name');
//use one line or the other
g_form.setValue('var_name', g_form_getValue('work_country_var_name'));
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 08:09 AM