How to make One Variable Change When Another is Altered in a Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 05:54 PM
I have created two catalog items, one for movies and one for video games. I have the movie and game choices connected to tables I've uploaded that include data like the prices and ratings for each title. Now, comes the hard part, having the "Rating" field on the catalog item automatically update when I change the game or movie to sync up with the rating found on their table entries.
Can anyone share a simple to edit and understand client script template for that purpose with me? Preferably something that is set up to simply reference either the record number or the title as a variable so that I don't have to type in 25 individual entries?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2022 08:54 AM
That's correct.
Well technically the AJAX part is from your client script (OnChange).
So the order would be:
-Create the script include that is client callable with the GlideRecord code
-In your form, create a client script that is triggered when your movie list changes (OnChange script). This script contains the AJAX code shown in my previous post.
-In the callback function (The one that contains the server result in the AJAX code), you must assign the result that has been returned by the script include to the proper variable using g_form.
If it doesn't work on the first try, here's a few things idea to troubleshoot it:
-Maybe gr.rating does not get converted to a string automatically. Try appending it to an empty string to troubleshoot (return gr.rating + "")
-If you don't see a result being displayed, here's how to troubleshoot it at every step:
1) Add an "alert) in your OnChange script to make sure it's being triggered correctly
2) Add a gs.info() at the beginning of your script include to make sure it gets called properly.
3) Add a gs.info(gr.rating + "") just before the return in your script include to make sure it does produce the expected value
4) Add an alert at the beginning of your callback function to make sure it gets called properly
5) Add a second alert in your callback function to show the result value (Make sure it's the right value)
If you run into issues, feel free to ask for help =D
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2022 02:42 PM
I've been trying to test my code, but now I've run into another issue. I try to run the catalog client script, but I keep getting an error message about "strict mode". I've attempted to disable it by unchecking the "Isolate Script box, still won't turn off the restriction. There's also something about a system property called "glide.script.block.client.globals" that it suggests to set to false, but I'm having trouble finding that.
Why is there even a feature like that that's so hard to turn off? -_-;