- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:15 PM
Hi all!
I'm looking for a way to check if a variable is read-only on client side.
Any idea how that can be done?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 03:50 AM
Actually, it's a bit complicated logic which we have put in place.
We have a review feature for non-fulfillers, on the same form which is used to submit the request.
For your information, we have a client script (CS3) available for setting the variable values only(not making read-only), which triggers on change of var_a, other than that of var_e.
For review feature to work, we are only setting the value in var_a , so it can trigger the already developed client script.
So let me summarize this:
onLoad (CS1) -> set the value in var_a -> triggers the (CS3) -> sets the value in all variables, including var_e -> triggers the (CS2) -> sets the variables read-only, except var_e and clears the value.
Now coming to your suggestion;
- CS2 & CS3 can't be merged as it would dissolve the functionality of CS3, which is required independent for other use cases (where the variables shouldn't be read-only).
I'm thinking not to reuse this feature and re-build the functionality once again in the CS1 itself, and exclude var_e setting and resetting feature there.
Thanks for your help!
Regards,
Aman Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2024 11:19 PM
what's your business requirement for this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 01:52 AM
Hi @Ankur Bawiskar !
thanks for your reply..
There are two client script in action:
1. Setting all the variables with values
2. Make all the variables read-only except one (let's say "var_e")
I need to clear the value from var_e which was set through client script 1, as well as make it editable manually after making them read-only using CS 2.
Trigger for the CS2 is onChange of the last variable being set, which is var_e (I used this approach to ensure that CS2 runs only when CS1 has done it's job).
Now when the user is inputting some value in var_e manually, it is getting cleared(as the script is triggering again).
I was trying to check if second last variable is read-only (which confirms the script has been executed previously), then it would return without doing anything.
PS: the CS1 has the logic reused for the other use cases as well, which I do not wanna alter.
Thanks for your attention and patient read!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 01:57 AM
your 1st CS is setting value
then why not check in 2nd CS if the var_e has value inside it or not
Also your 1st CS is onLoad or onChange?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 02:22 AM - edited 12-23-2024 02:23 AM
So, the first time when CS2 runs, var_e still has value, being set by CS1.
So that condition would avoid the execution for the first time also!
The 1st CS is onChnage of a variable.
Kind regards..