Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,600
Community Members
 
Community Events
165
Community Groups

JMWE - In Postfunction condition with multiple cases

Hi Team,

 

We are using JMWE add-on for sending the Email notification when request reaches the certain steps.

In Postfunction we added the conditions to get the Email Address(To Address).Pls find below Screenshot.

EmailCondtion.PNG

Our Requirement is, we want add around 50-60 conditions to get 'To address' based on request value. we want to achieve this with out any performance issues such as high load time.

Could you pls help how to achieve this with out any performance issue using JMWE add-on.

 

 

Thanks,

Loganayaki

1 answer

1 accepted

1 vote
Answer accepted

Hi @Loganayaki 

there won't be any performance impact with your implementation, but for readability purposes, you can alter it as such:

<%
def parent = issue.get("customfield_32924")?.get("null")?.value
def child = issue.get("customfield_32924")?.get("1")?.value
switch(parent) {
case "DAC":
switch(child) {
case "SERVE Rule Request": print "test1@abc.com"; return
case "Credit Rule Request": print "test2@abc.com"; return
default: print "default@abc.com"; return
}
case "SomethingElse":
switch(child) {
case "SERVE Rule Request": print "test1@abc.com"; return
case "Credit Rule Request": print "test2@abc.com"; return
default: print "default@abc.com"; return
}
default: print "default@abc.com"; return
}
%>

HI @David Fischer _Appfire_ ,

It is working. Thanks for your help. :)

But I have one question. why we have to print the the value , instead of returning the value?

I have tried below script . but it is not working.

switch(child) {
case "Test1": return "abc@xyz.com"
case "Test2": return "defg@xyz.com"
default: return "support@xyz.com"
}

 

Thanks,

Loganayaki R

That's because I used a <% ... %> block instead of a <%= ... %> block. The problem with <%= %> is that it expects a single expression, not a block of statements. There are ways around it, but I thought it'd be easier to use a <% %> block instead.

Got it . Thanks @David Fischer _Appfire_ .

 

 

Thanks,

Loganayaki

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you