Skip to content
Snippets Groups Projects
Commit 7e262d6d authored by Tobias Feldmann's avatar Tobias Feldmann
Browse files

Leadprocess workflow example

parent fb552825
No related branches found
No related tags found
No related merge requests found
Showing
with 254 additions and 18 deletions
......@@ -18,7 +18,7 @@ var recordSep = LeadImportUtils.getRecordSeparator(vars.get("$field.SENTENCESEPA
if(bindata != '' && filename != '')
{
var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata"));
if (mimeType == "application/vnd.ms-excel")
if (mimeType == "application/vnd.ms-excel" || mimeType == "text/csv")
{
var documentId = SingleBinaryUtils.insertMainDocument("LEADIMPORT", "IMPORTFILE", assignmentRowId, bindata, filename, "", SqlUtils.getBinariesAlias());
LeadImportUtils.loadImportFile(documentId, fieldSep, fieldLimit, recordSep, assignmentRowId, false, true);
......
......@@ -23,7 +23,7 @@ if (vars.get("$field.bindata") != "FILE NOT CHANGED")
if(bindata != '' && filename != '')
{
var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata"));
if (mimeType == "application/vnd.ms-excel")
if (mimeType == "application/vnd.ms-excel" || mimeType == "text/csv")
{
var binMetadata = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", assignmentRowId, false, SqlUtils.getBinariesAlias(), "");
......
......@@ -14,7 +14,7 @@
<name>Card</name>
<iconField>ICON</iconField>
<titleField>NAME</titleField>
<subtitleField>PROCESSINSTANCE_ID</subtitleField>
<subtitleField>DESCRIPTION</subtitleField>
<favoriteAction1>completeTask</favoriteAction1>
<entityField>#ENTITY</entityField>
</cardViewTemplate>
......@@ -36,10 +36,6 @@
<name>6523539d-2dba-4417-99c6-ddecdbe6c31b</name>
<entityField>ASSIGNEE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>ee07f936-133f-41c3-8ed8-716bd9bb4a8d</name>
<entityField>DESCRIPTION</entityField>
</entityFieldLink>
<entityFieldLink>
<name>7355affe-63da-4383-bb8a-00205410b47d</name>
<entityField>DUEDATE</entityField>
......@@ -48,10 +44,6 @@
<name>63697864-5b0b-471f-89fc-60621fecbaec</name>
<entityField>TARGET_ID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>232670b6-4923-4e8d-bfa0-8720e57e932a</name>
<entityField>ISACTIVE</entityField>
</entityFieldLink>
<entityFieldLink>
<name>d193bea1-a470-4403-bce7-446e3b398540</name>
<entityField>PRIORITY</entityField>
......
<?xml version="1.0" encoding="UTF-8"?>
<preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.2.1">
<preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.2.0">
<name>_____PREFERENCES_PROJECT</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<customized />
......@@ -92,5 +92,10 @@
<name>duplicates.dataBlockSize</name>
<property v="5000" />
</customIntegerProperty>
<customBooleanProperty>
<name>workflow.leadExample</name>
<description></description>
<property v="false" />
</customBooleanProperty>
</customProperties>
</preferences>
......@@ -3,6 +3,7 @@
<name>Classification_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/Classification_lib/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>LIBRARY</element>
</variants>
......
import("system.util");
import("system.vars");
import("system.db");
import("Sql_lib");
......@@ -173,4 +174,24 @@ ClassificationUtils.changeScoreName = function(pNewScoreName, pClassificationTyp
{
newWhere("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", pClassificationTypeId)
.updateData(true, "CLASSIFICATIONTYPE", ["SCORETYPE"], null, [pNewScoreName]);
}
\ No newline at end of file
}
/**
* Set a value for a classification type
*
* @param {String} pObjectType
* @param {String} pObjectId
* @param {String} pClassificationTypeId
* @param {String} pClassificationScoreId
*/
ClassificationUtils.setClassificationValue = function(pObjectType, pObjectId, pClassificationTypeId, pClassificationScoreId)
{
var newId = util.getNewUUID();
db.insertData("CLASSIFICATION", ["CLASSIFICATIONID", "OBJECT_TYPE", "OBJECT_ROWID", "CLASSIFICATIONTYPE_ID", "CLASSIFICATIONSCORE_ID"], null, [
newId,
pObjectType,
pObjectId,
pClassificationTypeId,
pClassificationScoreId,
]);
}
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>CreateSalesprojectTouchpoint_workflowService</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/CreateSalesprojectTouchpoint_workflowService/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>WORKFLOW</element>
</variants>
</process>
import("system.vars");
import("Salesproject_lib");
var variables = JSON.parse(vars.get("$local.value"));
var targetId = variables.targetId;
var touchpointType = variables.touchpointType;
var touchpointInfo = variables.touchpointInfo;
Salesproject.insertTouchPoint(targetId, touchpointType, touchpointInfo);
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>CreateSalesproject_workflowService</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/CreateSalesproject_workflowService/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>WORKFLOW</element>
</variants>
</process>
import("Classification_lib");
import("system.logging");
import("Sql_lib");
import("Attribute_lib");
import("system.result");
import("system.vars");
import("Salesproject_lib");
import("system.workflow");
var variables = JSON.parse(vars.get("$local.value"));
var objectRowId = variables.targetId;
var salesprojectName = variables.salesprojectName;
var id = Salesproject.createNewSalesprojectFromOrg(objectRowId, salesprojectName);
//Set the business as a classification for the salesproject
var classificationTypeId = newSelect("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID")
.from("CLASSIFICATIONTYPE")
.where("CLASSIFICATIONTYPE.SCORETYPE", "ScoreBranch")
.cell();
var classificationScoreId = newSelect("CLASSIFICATIONSCORE.CLASSIFICATIONSCOREID")
.from("CLASSIFICATIONSCORE")
.where("CLASSIFICATIONSCORE.TITLE", variables.business)
.cell();
if(classificationTypeId && classificationScoreId) {
ClassificationUtils.setClassificationValue("Salesproject", id, classificationTypeId, classificationScoreId);
}
//change the linked dataset from organisation to the new salesproject
var processVariables = {
"targetId": id,
"targetContext": "Salesproject"
}
workflow.setProcessInstanceVariables(vars.get("$local.uid"), processVariables)
import("system.workflow");
import("system.project");
import("Util_lib");
import("system.logging");
import("DuplicateScanner_lib");
......@@ -491,6 +493,22 @@ LeadImportUtils.insertOrg = function(pDataFields, pDataTypes, pFieldDef, pField
entityFieldValues = LeadImportUtils.getEntityFieldsOrg(OrgValues, ContactValues, AddrValues);
//Activate the lead workflow example in the custom properties
if(JSON.parse(project.getPreferenceValue("custom.workflow.leadExample", "false")))
{
var processVariables = {
"OrganisationId": orgid,
"targetId": contactId,
"recipientContactId": contactId,
"targetContext": "Organisation",
"salesprojectName": OrgValues["NAME"],
"documentTemplateId": "12da39a8-6fc9-4220-b09d-179cd611a814",
"business": ""
}
//start the example lead process instance for a new organisation lead
workflow.startProcessByKey("leadprocess", processVariables)
}
return new Array(orgid, contactId ,entityFieldValues, true);
}
//return the ids of the existing organisation so that people who work for the same organisation are assigned to them
......
......@@ -9,6 +9,8 @@ import("system.question");
import("Util_lib");
import("Keyword_lib");
import("system.neonTools");
import("KeywordRegistry_basic");
/**
* Methods used by the Salesproject.
* Do not create an instance of this!
......@@ -107,4 +109,43 @@ Salesproject.createNewSalesproject= function(pRelationId)
params["ContactId_param"] = pRelationId;
neon.openContext("Salesproject", null, null, neon.OPERATINGSTATE_NEW, params);
}
\ No newline at end of file
}
/**
* Create a new Salesproject from a organisation
*/
Salesproject.createNewSalesprojectFromOrg = function(pRelationId, pSalesprojectName)
{
var uid = util.getNewUUID();
db.insertData(
"SALESPROJECT",
["SALESPROJECTID", "CONTACT_ID", "PROJECTTITLE", "PROJECTCODE", "STARTDATE", "STATUS", "PHASE"],
null,
[uid, pRelationId, pSalesprojectName, Salesproject.getNextProjectNumber(),
vars.get("$sys.date"), $KeywordRegistry.salesprojectState$open(), $KeywordRegistry.salesprojectPhase$nqc()]);
return uid;
}
/**
* Insert a new touchpoint for the salesproject
*/
Salesproject.insertTouchPoint = function(pSalesprojectId, pTouchPoint, pInfo)
{
var uid = util.getNewUUID();
db.insertData(
"SALESPROJECT_TOUCHPOINT",
["SALESPROJECT_TOUCHPOINTID", "SALESPROJECT_ID", "ENTRYDATE", "INFO", "TOUCHPOINT"],
null,
[uid, pSalesprojectId, vars.get("$sys.date"), pInfo, pTouchPoint]);
return uid;
}
/**
* Set a new phase for the salesproject
*/
Salesproject.updateSalesprojectPhase = function(pSalesprojectId, pPhase)
{
newWhere("SALESPROJECT.SALESPROJECTID", pSalesprojectId)
.updateData(true, "SALESPROJECT", ["PHASE"], null, [pPhase]);
}
......@@ -4,6 +4,7 @@
<title>Send email</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/SendEmail_workflowService/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>WORKFLOW</element>
</variants>
......
import("Communication_lib");
import("system.tools");
import("system.result");
import("DocumentTemplate_lib");
import("system.vars");
import("Email_lib");
var variables = JSON.parse(vars.get("$local.value"));
var recipientContactId = variables.recipientContactId;
var documentTemplateId = variables.documentTemplateId;
var senderName = variables.senderName;
var mailSubject = variables.mailSubject;
var email = Email.fromTemplate(variables.documentTemplateId, variables.recipientContactId);
var sendResult = email.send();
var email = Email.fromTemplate(documentTemplateId, recipientContactId);
email.subject = mailSubject;
email.toRecipients = [CommUtil.getStandardMail(recipientContactId)];
//if we use @@instanceId in the mail body to track the user interaction, we replace it here with the instance id
email.body = email.body.replace("@@instanceId", vars.get("$local.uid"));
var sendResult;
if(senderName)
{
var senderUser = tools.getUser(senderName);
var senderContactId = senderUser[tools.PARAMS][tools.CONTACTID];
email.sender = CommUtil.getStandardMail(senderContactId);
sendResult = email.send(senderName);
}
else
{
sendResult = email.send();
}
result.string(sendResult);
\ No newline at end of file
import("Sql_lib");
import("Attribute_lib");
import("system.result");
import("system.vars");
var variables = JSON.parse(vars.get("$local.value"));
var attributeId = variables.attributeId;
var attributeName = variables.attributeName;
var attributeId;
if(attributeName)
{
attributeId = newSelect("AB_ATTRIBUTE.AB_ATTRIBUTEID")
.from("AB_ATTRIBUTE")
.where("AB_ATTRIBUTE.ATTRIBUTE_NAME", value)
.cell();
}
else
{
attributeId = variables.attributeId;
}
var value = variables.attributeValue;
var objectRowId = variables.targetId;
var objectType = variables.targetContext;
......
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>SetSalesprojectPhase_workflowService</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/SetSalesprojectPhase_workflowService/process.js</process>
<alias>Data_alias</alias>
<variants>
<element>WORKFLOW</element>
</variants>
</process>
import("KeywordRegistry_basic");
import("system.vars");
import("Salesproject_lib");
var variables = JSON.parse(vars.get("$local.value"));
var targetId = variables.targetId;
var phase = variables.salesprojectPhase;
Salesproject.updateSalesprojectPhase(targetId, phase);
import("system.result");
import("system.workflow");
var fallbackLocation = "https://www.adito.de";
function restget(getInputReq)
{
var request = JSON.parse(getInputReq);
var instanceId = request.query["id"];
var location = fallbackLocation;
if(instanceId)
{
var taskConfig = workflow.createConfigForLoadingTask();
taskConfig.processInstanceId(instanceId);
var task = JSON.parse(workflow.getTask(taskConfig));
var variables = JSON.parse(workflow.getTaskVariables(task.id));
if(variables.location)
{
location = variables.location;
}
workflow.completeTask(task.id, null);
}
request.response.header["Location"] = location;
request.response.httpStatusCode = 303;
return JSON.stringify(request);
}
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>workflowLinkTracking_rest</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/workflowLinkTracking_rest/process.js</process>
<publishAsWebservice v="false" />
<style>REST</style>
<alias>Data_alias</alias>
<variants>
<element>EXECUTABLE</element>
</variants>
</process>
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