Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
32edb5eb
Commit
32edb5eb
authored
3 years ago
by
Vinzent Broens
Committed by
Martin Groppe
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Marketing 1083564 copybulkmail
parent
2ce491ec
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
entity/BulkMail_entity/recordcontainers/db/onDBInsert.js
+53
-18
53 additions, 18 deletions
entity/BulkMail_entity/recordcontainers/db/onDBInsert.js
with
53 additions
and
18 deletions
entity/BulkMail_entity/recordcontainers/db/onDBInsert.js
+
53
−
18
View file @
32edb5eb
import
(
"
KeywordRegistry_basic
"
);
import
(
"
Communication_lib
"
);
import
(
"
Workflow_lib
"
);
import
(
"
Binary_lib
"
);
import
(
"
Sql_lib
"
);
...
...
@@ -28,28 +30,61 @@ if (template && template.content && BulkMailUtils.isValidTemplateType(template.t
SingleBinaryUtils
.
insert
(
"
BULKMAIL
"
,
"
DOCUMENT
"
,
bulkMailId
,
template
.
content
,
template
.
filename
);
}
var
contactIds
=
[];
// CopyBulkMail Recipients
if
(
vars
.
get
(
"
$param.CopyBulkMailId_param
"
)){
var
BulkMailParam
=
vars
.
get
(
"
$param.CopyBulkMailId_param
"
);
if
(
vars
.
get
(
"
$param.CopyBulkMailId_param
"
))
{
var
config
=
entities
.
createConfigForLoadingRows
()
.
entity
(
"
BulkMailRecipient_entity
"
)
.
provider
(
"
BulkMailRecipients
"
)
.
addParameter
(
"
BulkMailId_param
"
,
vars
.
get
(
"
$param.CopyBulkMailId_param
"
))
.
fields
([
"
CONTACT_ID
"
]);
var
copiedRecipients
=
entities
.
getRows
(
config
);
contactIds
=
copiedRecipients
.
map
(
function
(
pRecipient
)
var
copiedRecipients
=
newSelect
(
"
CONTACT_ID, EMAIL_ADDRESS, IS_TEST_RECIPIENT
"
)
.
from
(
"
BULKMAILRECIPIENT
"
)
.
join
(
"
CONTACT
"
,
"
BULKMAILRECIPIENT.CONTACT_ID = CONTACT.CONTACTID
"
)
.
where
(
"
BULKMAILRECIPIENT.BULKMAIL_ID
"
,
BulkMailParam
)
// check if there's a commrestriction
.
and
(
new
CommunicationSettingsCondition
()
.
emails
(
CommUtil
.
getStandardSubSqlMail
())
.
rejected
()
.
existNoSettings
()
.
buildCondition
())
.
table
()
var
sqlBuilder
=
new
SqlBuilder
();
var
inserts
=
copiedRecipients
.
map
(
function
([
contactId
,
email
,
test
])
{
return
pRecipient
[
"
CONTACT_ID
"
];
return
sqlBuilder
.
buildInsertStatement
({
"
BULKMAIL_ID
"
:
bulkMailId
,
"
CONTACT_ID
"
:
contactId
,
"
STATUS
"
:
$KeywordRegistry
.
bulkMailRecipientStatus
$pending
(),
"
EMAIL_ADDRESS
"
:
email
,
"
IS_TEST_RECIPIENT
"
:
test
},
"
BULKMAILRECIPIENT
"
,
"
BULKMAILRECIPIENTID
"
);
});
}
db
.
inserts
(
inserts
);
//CopyBulkMail TestRecipients
if
(
vars
.
getString
(
"
$param.PresetRecipients_param
"
))
contactIds
=
contactIds
.
concat
(
JSON
.
parse
(
vars
.
getString
(
"
$param.PresetRecipients_param
"
)));
copiedRecipients
=
newSelect
(
"
CONTACT_ID, EMAIL_ADDRESS
"
)
.
from
(
"
BULKMAILTESTRECIPIENT
"
)
.
join
(
"
CONTACT
"
,
"
BULKMAILTESTRECIPIENT.CONTACT_ID = CONTACT.CONTACTID
"
)
.
where
(
"
BULKMAILTESTRECIPIENT.BULKMAIL_ID
"
,
BulkMailParam
)
// check if there's a commrestriction
.
and
(
new
CommunicationSettingsCondition
()
.
emails
(
CommUtil
.
getStandardSubSqlMail
())
.
rejected
()
.
existNoSettings
()
.
buildCondition
())
.
table
()
if
(
contactIds
&&
contactIds
.
length
>
0
)
BulkMailUtils
.
addRecipients
(
bulkMailId
,
BulkMailUtils
.
filterNewRecipients
(
bulkMailId
,
contactIds
));
sqlBuilder
=
new
SqlBuilder
();
inserts
=
copiedRecipients
.
map
(
function
([
contactId
,
email
])
{
return
sqlBuilder
.
buildInsertStatement
({
"
BULKMAIL_ID
"
:
bulkMailId
,
"
CONTACT_ID
"
:
contactId
,
"
EMAIL_ADDRESS
"
:
email
},
"
BULKMAILTESTRECIPIENT
"
,
"
BULKMAILTESTRECIPIENTID
"
);
});
db
.
inserts
(
inserts
);
}
WorkflowSignalSender
.
inserted
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment