- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 08:42 AM - edited 01-06-2023 08:57 AM
Hi Community! Happy New Year!
I wrote an onChange catalog client script on a Variable named "Pickup Choice". This variable is type "Select Box" and has a choice list with choices like "Pickup" and "Ship to my Location".
The purpose of this script is to clear the mandatory status of the comments variable, which is made mandatory by a UI Action before the pickup choice is changed.
My issue that I found is that I tried to make the client script run only when oldValue == "Ship to my location" to signify the user selecting a different choice. However, I noticed that when I selected a new option, the oldValue was empty (but the newValue was correctly populated with the new choice).
Why could I not have access to oldValue? I'm trying to do this from the Platform UI with UI16 on a simple Catalog Item.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 09:10 AM
You might have to be sneaky with it. There is no direct way I'm afraid.
Create another variable that is not visible to the user ever and populate the value user selects each time in the field in question and set it in the hidden variable, read it from there when you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 08:53 AM
Hi,
Old value will not work in this case.
When it is a record on a table (not a catalog) and the record is loaded. At that tie the old value of the field is set (it is the value that comes from DB). Now if you change it 10 times without saving the form, the old value will not change but new value will change each time.
Hope that helps explains what the issue is why Old Value will not work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 08:58 AM
Thank you for your feedback Anurag. How could I grab the previous value of the Choice in this situation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 09:10 AM
You might have to be sneaky with it. There is no direct way I'm afraid.
Create another variable that is not visible to the user ever and populate the value user selects each time in the field in question and set it in the hidden variable, read it from there when you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 05:29 AM
Thank you Anurag! I ended up working around the problem like you mentioned. Happy New Year 2023!