Skip to content
Snippets Groups Projects
Commit e2f6dfd0 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Merge branch 'marketing_2002710_replace_contactid_in_weblink' into '2021.2.3'

[Projekt: xRM-Marketing][TicketNr.: 2002710][Weblink: Ersetzung einer contactid innerhalb der URL]

See merge request xrm/basic!1563
parents 0d2b9f9a 8fce96b6
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ import("system.db");
import("system.workflow");
import("system.tools");
import("FileUtil_lib");
import("system.text");
/**
* Functions for bulk mails.
......@@ -181,15 +182,23 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun, pUser, pAddition
.table()
.map(function ([placeholder, weblinkId, url, isRedirect])
{
var linkFn
if (Utils.toBoolean(isRedirect))
{
var linkFn = function (pContactId)
linkFn = function (pContactId)
{
return baseUrl + "link=" + weblinkId + "&log=" + mailLogIds.get(pContactId) + additionalParameterString;
}
return new Placeholder(placeholder, Placeholder.types.CALLBACKFUNCTION, linkFn);
}
return new Placeholder(placeholder, Placeholder.types.FIXEDVALUE, url);
else
{
linkFn = function (pContactId)
{
return StringUtils.replaceAll(url, "{@contactid@}", pContactId);
}
return new Placeholder(placeholder, Placeholder.types.CALLBACKFUNCTION, linkFn);
}
});
var webviewFn = function(pContactId)
......@@ -1012,15 +1021,22 @@ BulkMailUtils.getEmlFile = function(pBulkMailId,pMailRunId, pMailLogId)
* The id of the link.<br>
* @param {String} pBaseUrl <p>
* The base url for relative links<br>
*
* @param {String} pMailLogId <p>
* The mail log id for contact id replacement<br>
* @return {String} <p>
* The url<br>
**/
BulkMailUtils.getRedirectLink = function(pLinkId, pBaseUrl)
BulkMailUtils.getRedirectLink = function(pLinkId, pBaseUrl, pMailLogId)
{
if (pLinkId)
if (pLinkId && pMailLogId)
{
var contactId = newSelect("CONTACT_ID")
.from("MAIL_LOG")
.where("MAIL_LOG.MAIL_LOGID", pMailLogId)
.cell();
var link = newSelect("WEBLINK.URL").from("WEBLINK").where("WEBLINK.WEBLINKID", pLinkId).cell();
link = StringUtils.replaceAll(link, "{@contactid@}", contactId);
if(link[0] == "/")
{
link = pBaseUrl + link;
......
......@@ -16,7 +16,7 @@ function restget (pRequest)
var workflowKey = request.query.workflowkey
var ipAddress = BulkMailUtils.getIpAddressFromHeader(request.header);
var origin =request.header["X-forwarded-proto"]+"://"+request.header["X-forwarded-host"]
var redirectLink = BulkMailUtils.getRedirectLink(linkId, origin);
var redirectLink = BulkMailUtils.getRedirectLink(linkId, origin, mailLogId);
var UserAgentObject = new UAParser(request.header["User-agent"]).getResult();
BulkMailUtils.insertClick(mailLogId, ipAddress, linkId, UserAgentObject.browser.name, UserAgentObject.os.name, UserAgentObject.device.type);
......
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