Need assistance with logic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 03:27 AM
Hi All,
I have a catalog item in ServiceNow with five variables, each with four choices. Each choice has an associated score.
For example:
Variable 1:
- Choice 1: Score 50
- Choice 2: Score 40
- Choice 3: Score 30
- Choice 4: Score 20
(Note: Scores are only for the logic not available on catalog item)
I want to set the value of a new read-only variable based on the total score of the choices selected for the first five variables. If the total score is 70 or higher, the read-only variable should be set to "Very high"; If the total score in between 50 to 69 then set to "high" and so on...
New read-only variable auto-populate value based on total score:
SCORE | Value |
1 | Very Low |
20 | Low |
30 | Medium |
50 | High |
70 | Very High |
How can I achieve this using a Catalog Client Script in ServiceNow?
If I used onChange client script on last variable then there is possibility end user will change the value of previous varibles then it will cause issue..please suggest approach(I cant used flow designer because already I m using Workflow for the same catalog)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 03:59 AM
You will need a client script on each variable, since each variable can change the outcome. Every change should recalculate.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 02:17 AM
Hi @Mark Manders ,
Thanks for your reply...actually I have total 19 variable, So creating 19 onChange scripts is not a good way...Is there any other way where I can handle multiple onchange in single script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 03:36 AM
Do you need the calculated field on the form itself? If so: you will need to have the calculation triggered on each field that can change it (in your case 19). If it is just something you need in the backend: get the final calculation on submit of everything. The fact that you are calculating one outcome depending on 19 fields is something to take a look at. Because I agree that it's not a good way to create 19 onChange client scripts, but it is to resolve your own requirement. Why do you need 19 variables to get to the final outcome AND do you need to change that outcome on every selection.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 05:29 AM
Hi @Mark Manders ,
Yes, I need the calculated field on the form itself with read only and I don't need to change that outcome on every selection. I only want the calculated field outcome on last variable but in this case There might be a scenario like end user will change previous fields values.