Skip to content
Snippets Groups Projects
Commit 367d57bc authored by Martin Groppe's avatar Martin Groppe
Browse files

Merge branch 'm_1080363_commsettingWorkflow' into '2021.0.3'

1080363 optimized setCommunicationSetting_workflowService

See merge request xrm/basic!917
parents 140979dc 467e8357
No related branches found
No related tags found
No related merge requests found
......@@ -673,10 +673,16 @@ BulkMailUtils.startBulkmailWorkFlow = function(pMailLogId, pLinkId)
.from("WEBLINK")
.where("WEBLINK.WEBLINKID", pLinkId)
.arrayRow();
var contactId = newSelect("CONTACT_ID")
.from("MAIL_LOG")
.where("MAIL_LOG.MAIL_LOGID", pMailLogId)
.cell();
var variables = {
"mailLogId": pMailLogId,
"linkId": pLinkId
"linkId": pLinkId,
"contactId": contactId
};
if (actionType == $KeywordRegistry.weblinkActionType$startWorkflow() && workflowKey)
{
......
......@@ -4,6 +4,7 @@
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/SetCommunicationSetting_workflowService/process.js</process>
<alias>Data_alias</alias>
<serviceTaskParameterProcess>%aditoprj%/process/SetCommunicationSetting_workflowService/serviceTaskParameterProcess.js</serviceTaskParameterProcess>
<variants>
<element>WORKFLOW</element>
</variants>
......
......@@ -6,19 +6,36 @@ import("system.vars");
var variables = JSON.parse(vars.get("$local.value"));
var contactId = variables.contactId || variables.targetId;
var channelType = variables.channelType;
var channelId = variables.channelId;
var medium = variables.medium || "";
var channelId = variables.channelId || "";
var status = variables.status || $KeywordRegistry.communicationSettingStatus$rejected();
var settingsId = newSelect("COMMUNICATIONSETTINGSID")
var settingsIdSql = newSelect("COMMUNICATIONSETTINGSID")
.from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID", contactId)
.and("COMMUNICATIONSETTINGS.CHANNEL_TYPE", channelType)
.and("COMMUNICATIONSETTINGS.CHANNEL_ID", channelId)
.cell();
.and("COMMUNICATIONSETTINGS.CHANNEL_TYPE", channelType);
if (medium)
{
settingsIdSql.and("COMMUNICATIONSETTINGS.MEDIUM", medium);
}
else
{
settingsIdSql.and("COMMUNICATIONSETTINGS.MEDIUM is null");
}
if (channelId)
{
settingsIdSql.and("COMMUNICATIONSETTINGS.CHANNEL_ID", channelId);
}
else
{
settingsIdSql.and("COMMUNICATIONSETTINGS.CHANNEL_ID is null");
}
var settingsId = settingsIdSql.cell();
if (settingsId)
{
newWhere("COMMUNICATIONSETTINGS.COMMUNICATIONSETTINGSID")
newWhere("COMMUNICATIONSETTINGS.COMMUNICATIONSETTINGSID", settingsId)
.updateFields({"STATUS": status});
}
else
......
import("KeywordRegistry_basic");
import("system.result");
import("KeywordData_lib");
import("Workflow_lib");
result.object([
new WorkflowServiceTaskParameter("channelType", "Channel type", WorkflowServiceTaskParameter.ENUM(), _getKeywords($KeywordRegistry.communicationChannelType())),
new WorkflowServiceTaskParameter("medium", "Medium", WorkflowServiceTaskParameter.ENUM(), _getKeywords($KeywordRegistry.communicationMediumCampaign())),
new WorkflowServiceTaskParameter("status", "Status", WorkflowServiceTaskParameter.ENUM(), _getKeywords($KeywordRegistry.communicationSettingStatus()))
]);
function _getKeywords (pContainer)
{
return KeywordData.getSimpleData(pContainer).map(function (item) {return {id : item[0], name : item[1]};});
}
\ No newline at end of file
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