Using automation to calculate a multi select list values.
Asked by Mat Levell:

Hey all, Im trying to created a weighted priority score based on user selecting questions in a multi select list.   
I first attempted to use a lookup table (similar to this [thread](https://community.atlassian.com/t5/Automation-questions/Lookup-tables-to-store-values/qaq-p/2465066)) but I got stuck. I couldn't event get anything to wire to the Priority score (number field).  

![Screenshot 2024-08-14 at 12.53.46?PM.png](/t5/image/serverpage/image-id/342206i48738CC6B1D5FD3F/image-size/large?v=v2&px=999 "Screenshot 2024-08-14 at 12.53.46?PM.png")![Screenshot 2024-08-14 at 12.54.41?PM.png](/t5/image/serverpage/image-id/342207iE6BE6A10F7D1B5E3/image-size/large?v=v2&px=999 "Screenshot 2024-08-14 at 12.54.41?PM.png")

I then abandoned the lookup table and tried multiple if statement

{{#=}}  
{{#if(issue.customfield_10295.value.contains("Is the issue present on all vehicles?"))}}20{{/}}  
+  
{{#if(issue.customfield_10295.value.contains("Is the issue present on all models?"))}}50{{/}}  
+  
{{#if(issue.customfield_10295.value.contains("Does the issue result in a model being banned?"))}}100{{/}}  
{{/}}

![Screenshot 2024-08-15 at 2.29.25?PM.png](/t5/image/serverpage/image-id/342208iFECD380E768E8103/image-size/large?v=v2&px=999 "Screenshot 2024-08-15 at 2.29.25?PM.png")

Any help would be amazing.


Answers:
author: Kalyan Sattaluri
body: Hello [@Mat Levell](/t5/user/viewprofilepage/user-id/5568611)

Please try to loop through the values and check individually...

{{#=}}0  
{{#customfield_10295}}   
{{#if(equals(value,"Is the issue present on all vehicles?"))}} + 20 {{/}}   
{{#if(equals(value,"Is the issue present on all models?"))}} + 50 {{/}}   
{{#if(equals(value,"Does the issue result in a model being banned?"))}} + 100 {{/}}  
{{/}}  
{{/}}

I just copied values from your example and if its not working, please try to log your values first and make sure the if conditions are evaluating correctly.. Hope it helps. Thanks!

comments: author: Mat Levell
body: [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) This worked but I started top get into problems when I added too many questions. Is there a character limit in the simple field? When I try to put this in the advanced field I get and error saying "Error while parsing additional fields. Not valid JSON."

{{#=}}0

{{#customfield_10295}}

{{#if(equals(value,"Is the issue present on all vehicles?"))}} + 20 {{/}}

{{#if(equals(value,"Is the issue present on all models?"))}} + 50 {{/}}

{{#if(equals(value,"Does the issue result in a model being banned?"))}} + 100 {{/}}

{{#if(equals(value,"Does the issue make the vehicles effected unusable?"))}} + 50 {{/}}

{{#if(equals(value,"Does the issue happen more than once a day?"))}} + 10 {{/}}

{{#if(equals(value,"Does the issue happen more than once a run?"))}} + 20 {{/}}

{{#if(equals(value,"Is this issue blocking a performance work stream?"))}} + 50 {{/}}

{{#if(equals(value,"Is this issue blocking an internal work stream?"))}} + 50 {{/}}

{{/}}

{{/}}  
![Screenshot 2024-08-27 at 9.36.14?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/344090i371E5C1519A0924E/image-size/large?v=v2&px=999 "Screenshot 2024-08-27 at 9.36.14?AM.png")


author: Mat Levell
body: [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) sorry to ping you again but Im pretty stuck here.


author: Kalyan Sattaluri
body: Hello [@Mat Levell](/t5/user/viewprofilepage/user-id/5568611)

I am not aware of any limitations to the count of If statement so I would have expected it to work.

This error --. "Error while parsing additional fields. Not valid JSON." usually means something is off with syntax but scanning through your post, syntax looks correct.

Have your tried to reduce number of if conditions 1 by 1 and check if fewer ones work? For ex, you have 8 statements now, have you tried to remove 1 and check if 7 works etc..

If lets say 5 if conditions work, and rest of the 3 dont.. an alternative is to break up your check into multiple smaller pieces..

So, you could create a variable and assign it the first 5 checks output.

Then create another variable and add next 3/remaining to previous value..

so you could try this work around..


author: Mat Levell
body: So [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) i think I had a typo somewhere, I rebuilt each line individually and I was able to get the logic working. Thanks for your help!


author: Christopher Yen
body: Hi [@Mat Levell](/t5/user/viewprofilepage/user-id/5568611)

Welcome to the community!  

Can you try this modified statement? I'm wondering if the if block end tags are causing an issue

```
{{#=}}
{{#if(issue.customfield_10295.value.contains("Is the issue present on all vehicles?"))}}20{{/if}}
+
{{#if(issue.customfield_10295.value.contains("Is the issue present on all models?"))}}50{{/if}}
+
{{#if(issue.customfield_10295.value.contains("Does the issue result in a model being banned?"))}}100{{/if}}
{{/}}
```

comments: author: Mat Levell
body: [@Christopher Yen](/t5/user/viewprofilepage/user-id/5051689) Nope sadly no go.  
![Screenshot 2024-08-16 at 9.31.43?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/342229iE8709A87AE20ED74/image-size/large?v=v2&px=999 "Screenshot 2024-08-16 at 9.31.43?AM.png")


Tags: automation

cloud

jira-service-management

jira-service-management-cloud