We're using JEMH, to intercept e-mails from users and extracting data from the e-mail to fill-in certain fields.
One of the things we've configured in JEMH is a script mapping rule, where we want to extract a certain part from an email and map this via Velocity into a custom field, which uses Insight data.
Example: From = role@vessel.domain.name
So in the end we want vessel to remain as a value, so it can be mapped in the insight custom field.
A nice approach would be using regex, but we lack the java expertise to nail this one.
#set($regex = "")
#foreach ($from in $message.getHeader("From"))
$from.replace($regex, "")
#end
Hi Frederik,
For setting a custom field based on a fixed set of email addresses I would use a project mapping domain rule, however it sounds like this sub-domain part is more dynamic/unpredictable.
Two different ways to approach this (choose one):
Velocity driven custom field value
A difficult one as we don't currently expose any regex utilities via this velocity script context. However, a (quite hacky) solution:
#foreach ($from in $message.getFrom())
#set ($fromAddress = $from.getAddress())
#if ($fromAddress)
$fromAddress.replaceAll(".+@","").replaceAll("\.domain\.name","")
#break
#end
#end
Setting field via script rule (issue creation only)
//you may have a match condition already, if so ignore this block
if (yourmatchcondition){
result.setMatch(true);
}
//this block will set a custom field with a regex extracted value like "vessel"
if (fromAddress && fromAddress.getAddress()){
var regex = /.+@([^\.]+)\.domain\.name/;
var address = fromAddress.getAddress();
var results = address.match(regex);
if (results && results.length > 1){
resultMap.put("your custom field name or id",results[1]);
}
}
Note that both approaches require you to know how to/be able to set your custom field type with a basic string value.
Setting via Script Field Processor
if (fromAddress && fromAddress.getAddress()){
var regex = /.+@([^\.]+)\.domain\.name/;
var address = fromAddress.getAddress();
var results = address.match(regex);
if (results && results.length > 1){
resultMap.put("your custom field name or id",results[1]);
}
}
If you need further help, raise a support request with us (The Plugin People) .
Relevant links:
Hi @Mike Harrison _The Plugin People_ using your guidance, we've been successful in implementing a couple off features using the code above.
Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.