Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Problem with Simple scripted validator

Mohamed El Taweel April 17, 2018 edited

Need to return true if and only if the following condition is true

the customfield ="CTI Alert" or  (the user in group TIER2 and customfield !="CTI Alert")


import com.atlassian.jira.component.ComponentAccessor;
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("11504");
 
def value = (String)issue.getCustomFieldValue(customField);    

if (value = "CTI Alert")  || (value != "CTI Alert") && isUserMemberOfGroup('Tier2')

{
   return true;
 else
   return false;

}

 

What could be the problem and what is the correct syntax?

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2018

What is the error? I am not a compiler, but I can see two problems

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11504");

if(( (value = "CTI Alert")  || (value != "CTI Alert")) && isUserMemberOfGroup("Tier2"))

Mohamed El Taweel April 18, 2018 edited

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor;
CustomField customField_name = customFieldManager.getCustomFieldObjectByName('Incident Source');

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11504");

 
def value = (String)issue.getCustomFieldValue(customField);    

if(( (value = "CTI Alert")  || (value != "CTI Alert")) && isUserMemberOfGroup("Tier2"))
   return true;
 else
   return false;

 

Currently testing this, seems no errors raised

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2018

Try like this:

import com.atlassian.jira.component.ComponentAccessor;
def customField_name = customFieldManager.getCustomFieldObjectByName('Incident Source');

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11504");

 
def value = (String)issue.getCustomFieldValue(customField);    

if(( (value = "CTI Alert")  || (value != "CTI Alert")) && isUserMemberOfGroup("Tier2"))
   return true;
 else
   return false;

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events