Skip to content
Snippets Groups Projects
Commit 7f690fb0 authored by Vinzent Broens's avatar Vinzent Broens Committed by Martin Groppe
Browse files

Service_mailbridge&servicemail

parent 8c190d57
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,5 @@ import("KeywordRegistry_basic");
import("system.vars");
import("system.result");
result.object(vars.get("$field.KIND") != $KeywordRegistry.documentTemplateType$attachment())
\ No newline at end of file
result.object(vars.get("$field.KIND") != $KeywordRegistry.documentTemplateType$attachment()
&& vars.get("$field.KIND") != $KeywordRegistry.documentTemplateType$signature());
\ No newline at end of file
......@@ -3,9 +3,16 @@ import("Util_lib");
import("system.neon");
import("system.vars");
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET && vars.get("$field.textbox"))
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
{
var preview = vars.get("$field.EMAIL_BODY_CONTENT")
preview = StringUtils.replaceAll(preview.toString(), "{@Service@}", vars.get("$field.textbox"));
result.string(preview);
if (vars.get("$field.textbox"))
{
preview = StringUtils.replaceAll(preview.toString(), "{@Service@}", vars.get("$field.textbox"));
}
else
{
preview = StringUtils.replaceAll(preview.toString(), "{@Service@}", "");
}
result.string(preview);
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ var TicketfieldValues = {};
var fromEmail = vars.get("$field.from");
var subject = vars.get("$field.subject");
var contentHtml = vars.get("$field.EMAIL_BODY_CONTENT");
var contentHtml = vars.get("$field.EMAIL_BODY_CONTENT.displayValue");
var contactId = vars.get("$param.ContactId_param");
......
......@@ -20,13 +20,13 @@ if( str_requestorContactId)
.and( "communication.MEDIUM_ID in ('COMMPHONE', 'COMMMOBIL')")
.orderBy("communication.ISSTANDARD desc")
.cell();
if(str_email)
if(str_email && vars.exists("$field.CommEMail"))
{
neon.setFieldValue("$field.CommEmail",
str_email
);
}
if(str_phone)
if(str_phone && vars.exists("$field.CommPhone"))
{
neon.setFieldValue("$field.CommPhone",
str_phone
......
......@@ -58,7 +58,7 @@ TicketMailbridgeUtils.insertLog = function(pTicketId, pDescription)
* @param {String} pSpecificRecipients <p>
* Recipients (Mail address) of the incoming mail<br>
* @return {Array} <p>
* Array of Ids of matching Inboxes
* Array of inboxes
*/
TicketMailbridgeUtils.getInbox = function (pSpecificRecipients)
{
......@@ -67,6 +67,24 @@ TicketMailbridgeUtils.getInbox = function (pSpecificRecipients)
.from("INBOX")
.leftJoin("MAILSIGNATURE", "INBOX.INBOXID = MAILSIGNATURE.INBOX_ID")
.whereIfSet("INBOX.EMAIL_ADDRESS", pSpecificRecipients, SqlBuilder.IN())
.or("MAILSIGNATURE.MAIL_ADDRESS", pSpecificRecipients, SqlBuilder.IN())
.arrayRow();
return inboxID;
}
/*
* Find default inbox via default mailsignature
*
* @return {Array} <p>
* Array with ID, Reopen delay and mail-address of the inbox with the default mailsignature
*/
TicketMailbridgeUtils.getDefaultInbox = function ()
{
var inboxID = new SqlBuilder()
.select(["INBOX.INBOXID","INBOX.REOPEN_DELAY", "INBOX.EMAIL_ADDRESS"])
.from("INBOX")
.leftJoin("MAILSIGNATURE", "INBOX.INBOXID = MAILSIGNATURE.INBOX_ID")
.where("MAILSIGNATURE.DEFAULTSIGNATURE", 1)
.arrayRow();
return inboxID;
}
......@@ -87,37 +105,61 @@ TicketMailbridgeUtils.getInbox = function (pSpecificRecipients)
*/
TicketMailbridgeUtils.getInboxInformationAllRecipients = function(pRecipients, pSender, possibleBCC, possibleBCCUnfiltered)
{
var inboxObj = {};
var inboxObj = {};
var inboxFound = false;
var inboxInformation;
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(pRecipients);
// found an Inbox?
if(inboxObj.inboxID.length > 0)
{
inboxInformation = TicketMailbridgeUtils.getInboxInformation(pRecipients,inboxObj["inboxID"][0]);
inboxObj["reoplenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
}
else // try to find some from possible BCC without INBOX-Mails
// try to find an Inbox via Recipients
if (pRecipients != "")
{
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(possibleBCC);
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(pRecipients);
if(inboxObj.inboxID.length > 0)
{
TicketMailbridgeUtils.getInboxInformation(possibleBCC,inboxObj["inboxID"][0])
inboxObj["reoplenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
}
else
{
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(possibleBCCUnfiltered);
if(inboxObj.inboxID.length > 0)
{
TicketMailbridgeUtils.getInboxInformation(possibleBCCUnfiltered,inboxObj["inboxID"][0])
inboxObj["reoplenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
}
inboxInformation = TicketMailbridgeUtils.getInboxInformation(pRecipients,inboxObj["inboxID"][0]);
inboxObj["reopenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
inboxFound = true;
}
}
// try to find inbox from possible BCC without INBOX-Mails
if (possibleBCC != "" && inboxFound == false )
{
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(possibleBCC);
// found an Inbox?
if(inboxObj.inboxID.length > 0)
{
inboxInformation = TicketMailbridgeUtils.getInboxInformation(possibleBCC,inboxObj["inboxID"][0]);
inboxObj["reopenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
inboxFound = true;
}
}
// use BACKUP INBOX-Mails
if (possibleBCCUnfiltered != "" && inboxFound == false )
{
inboxObj["inboxID"] = TicketMailbridgeUtils.getInbox(possibleBCCUnfiltered);
// found an Inbox?
if(inboxObj.inboxID.length > 0)
{
inboxInformation = TicketMailbridgeUtils.getInboxInformation(possibleBCCUnfiltered,inboxObj["inboxID"][0]);
inboxObj["reopenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
inboxFound = true;
}
}
// else use the Inbox with the default mailsignature
if (inboxFound == false)
{
inboxObj["inboxID"] = TicketMailbridgeUtils.getDefaultInbox();
// found an Inbox?
if(inboxObj.inboxID.length > 0)
{
inboxInformation = TicketMailbridgeUtils.getInboxInformation(possibleBCCUnfiltered,inboxObj["inboxID"][0]);
inboxObj["reopenDelay"] = inboxInformation[0];
inboxObj["mailSignatureID"] = inboxInformation[1];
inboxFound = true;
}
}
inboxObj["filterArray"] = newSelect("RTRIM(COMPONENT), searchterm, TICKETTEMPLATE_ID, "
+ "( case when ifnull(INBOXFILTERGROUP.PRIORITY,999) = 0 then 999 "
......@@ -174,12 +216,24 @@ TicketMailbridgeUtils.getInboxInformationAllRecipients = function(pRecipients, p
*/
TicketMailbridgeUtils.getInboxInformation = function(pSpecificRecipients, pInboxId)
{
var reopenDelay = newSelect("INBOX.INBOXID, INBOX.REOPEN_DELAY ")
if (pSpecificRecipients != "")
{
var reopenDelay = newSelect("INBOX.REOPEN_DELAY ")
.from("INBOX")
.leftJoin("MAILSIGNATURE", "MAILSIGNATURE.INBOX_ID = INBOX.INBOXID")
.whereIfSet("INBOX.EMAIL_ADDRESS", pSpecificRecipients, SqlBuilder.IN())
.or("MAILSIGNATURE.MAIL_ADDRESS", pSpecificRecipients, SqlBuilder.IN())
.arrayRow()[1];
.cell();
}
else
{
var reopenDelay = newSelect("INBOX.REOPEN_DELAY ")
.from("INBOX")
.leftJoin("MAILSIGNATURE", "MAILSIGNATURE.INBOX_ID = INBOX.INBOXID")
.whereIfSet("MAILSIGNATURE.DEFAULTSIGNATURE", 1)
.cell();
}
var mailSignatureSelect =
[
......@@ -663,29 +717,35 @@ TicketMailbridgeUtils.createTicket = function(pMailObject, pFilterResult, pInbox
// sending Automatic Answeremail
if(answerMail != "" && answerMail != undefined && answerMailActive !="" && answerMailActive == true)
{
logging.log(answerMail);
var eml = new Email();
eml.sender = mailRec || inboxUser;
eml.subject = ticketSub +" ["+ ticketCode +"]";
var eml = new Email();
// use answer mail address, if answer mail address is set for the selected inbox
var commAddr = pInboxObj.mailSignatureID[6]; // answer_mail_address
if (commAddr)
{
eml.sender = commAddr || inboxUser;
}
else
{
eml.sender = mailRec || inboxUser;
}
eml.body = DocumentTemplateUtils.getTemplate(answerMail, false) + "\n"+ DocumentTemplateUtils.getTemplate(signature, false) ;
eml.toRecipients = [persFrom];
logging.log(JSON.stringify(DocumentTemplateUtils.getTemplate(answerMail)));
// overwrite eml.body with individual answer, if individual answer template is set for the selected ticket template
// use individual answer, if individual answer template is set for the selected ticket template
var bodyDocuTempl = DocumentTemplateUtils.getTemplate(signature, false);
var indiAns = TicketTemplateUtils.checkIndividualAnswer(ticketTemplateId[0]);
if(indiAns !="" && indiAns != undefined)
{
eml.body = DocumentTemplateUtils.getTemplate(indiAns, false) + "\n"+ DocumentTemplateUtils.getTemplate(signature, false);
eml.body = StringUtils.replaceAll(bodyDocuTempl.toString(), "{@Service@}", DocumentTemplateUtils.getTemplate(indiAns, false));
}
// overwrite eml.sender with answer mail address, if answer mail address is set for the selected inbox
var commAddr = pInboxObj.mailSignatureID[6]; // answer_mail_address
if (commAddr)
eml.sender = commAddr || inboxUser;
else
{
eml.body = StringUtils.replaceAll(bodyDocuTempl.toString(), "{@Service@}", DocumentTemplateUtils.getTemplate(answerMail, false));
}
eml.subject = ticketSub +" ["+ ticketCode +"]";
eml.toRecipients = [persFrom];
var senderUser = tools.getUserByAttribute(tools.EMAIL, [inboxUser], tools.PROFILE_FULL);
// If it works then...
if( eml.send(senderUser[tools.TITLE]))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment