Filed required based on greater than condition
Asked by Devi Gattu:

Hi Team ,

Need your help on script so I have custom fields called as "initiated by" drop down values are "issue Owner" and "JVm" and another custom field called as "closed date" and another field called as "review date" and another custom field called as "closure review date" so when user select issue Owner in "initiated by" field and user give "closed date" field is greater than "review date" then "closure review date" should be mandatory or else if "closed date" is less than "review date" then "closure review date" should be optional

I tried with some script but it's could not help, could you please help with this task


Answers:
author: Ling Ng
body: Hi Devi,

I was able to replicate your use case using ScriptRunner Behaviours. You may want to reference the script that I used here (<https://bitbucket.org/Adaptavist/workspace/snippets/bqyz6R/scriptrunner-dc-behaviour-check-the-value>).

Make sure you've also added each of the 4 fields in Behaviours.![Screen Shot 2024-08-22 at 16.38.57 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/343165i7BB5D51F367860C5/image-dimensions/219x232?v=v2 "Screen Shot 2024-08-22 at 16.38.57 PM.png")

Hope this helps! If you still can't get it to work - I would recommend you to open a [Support Ticket](https://the-adaptavist-group-support.atlassian.net/servicedesk/customer/portals) with us for one of our Support Engineers to investigate and work with you.


author: Hauke Bruno Wollentin
body: I assume you are using ScriptRunner Behaviours for that?

Could you provide the script you have so far?

comments: author: Devi Gattu
body: *** ** * ** ***

Hi [@Hauke Bruno Wollentin](/t5/user/viewprofilepage/user-id/5238429)

Thanks for the quick reply,

I am sharing the code here, please check


author: Devi Gattu
body: ![Screenshot_20240819_165155.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/342438i904453876A15A3DA/image-size/large?v=v2&px=999 "Screenshot_20240819_165155.jpg")


author: Hauke Bruno Wollentin
body: Where did you place this code? You aren't using ScriptRunner Behaviours aren't you?

Also: anything in the logs? You also could try to add some debug logging in your if-statements to check if conditions are true or not.


author: Devi Gattu
body: Hi ,

I have placed in script runner behaviour and I added debug log also so after the execution, it shows "no logs found in this execution".


author: Hauke Bruno Wollentin
body: Another guess, do you use custom field translation? We ran into this and _thought_ that the custom field name will be the same for Behaviours. But in fact it is the translation based on the configured language of a user ?

This is our solution so far:

```
switch (usersLocale) {

case "de_DE":
fieldName = "Beschreibung"
break

case "it_IT":
fieldName = "Descrizione"
break

default:
fieldName = "Description"

}

def field = getFieldByName(fieldName)
```

While "usersLocale" comes from *com.atlassian.jira.user.UserLocaleStore*

Also I'm not sure about the "@BaseScript" decorator you are using. I can't find this in the documentation, also we aren't using it as well.

But in general your script _should_ work


Tags: data-center

jira-data-center

jira-server

server