JMWE - In Postfunction condition with multiple cases

Loganayaki June 22, 2022

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
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 22, 2022

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
}
%>
Loganayaki June 27, 2022

HI @David Fischer ,

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

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2022

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.

Loganayaki June 28, 2022

Got it . Thanks @David Fischer .

 

 

Thanks,

Loganayaki

Suggest an answer

Log in or Sign up to answer