Skip to content
Snippets Groups Projects
Commit 39de794b authored by Benjamin Ulrich's avatar Benjamin Ulrich :speech_balloon:
Browse files

[Projekt: xRM-Sales][TicketNr.: 1065539][Vertriebsprojekt: Mitglieder: Filter funktionieren ]

parent bd1baf4c
No related branches found
No related tags found
No related merge requests found
......@@ -207,7 +207,6 @@
</entityProvider>
<entityProvider>
<name>WithDistrictResponsibles</name>
<recordContainer>jdito</recordContainer>
</entityProvider>
<entityField>
<name>UID</name>
......@@ -450,91 +449,5 @@
</linkInformation>
</linkInformation>
</dbRecordContainer>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<isFilterable v="true" />
<contentProcess>%aditoprj%/entity/Member_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<onInsert>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onInsert.js</onInsert>
<onUpdate>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
<onDelete>%aditoprj%/entity/Member_entity/recordcontainers/jdito/onDelete.js</onDelete>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECTMEMBERID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACT_ID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACT_ID.displayValue</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACTROLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>DEPARTMENT.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ICON.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>IMAGE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>MEMBERROLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>MEMBERROLE.displayValue</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECT_ROWID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECT_TYPE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ORG_ORGID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ORGANISATION_NAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_FIRSTNAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_FULL_NAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_LASTNAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_PERSID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_SALUTATION.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_TITLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>POSITION.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>TARGETCONTEXT.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>recordType.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>MST_MEMBERROLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_ATTR_LOYALTY.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
= Member_entity
Manages the project team in the sales project and in the campaign
This entity has two recordContainers:
* db
* jdito
While for the must purposes the `db`-recordContainer is perfectly fine to use there is one case necessary for the `jdito`-recordContainer:
Salesproject memebers are loaded via the ``-provider and therefor use the `jdito`-recodContainer. This recordContainer first collects the data from
the `db`-rc and then loads additional memebers of the salesprojects district. The additional members are not modifyable, while those from the
`db`-rc are.
\ No newline at end of file
Manages the project team in the sales project and in the campaign
\ No newline at end of file
import("AttributeRegistry_basic");
import("Util_lib");
import("system.translate");
import("system.result");
import("system.vars");
import("system.entities");
import("KeywordRegistry_basic");
import("Sql_lib");
var idValues = vars.get("$local.idvalues");
var filter = vars.get("$local.filter");
var memberLoadingConfig = entities.createConfigForLoadingRows()
.entity("Member_entity")
.provider("Links")
.addParameter("ObjectRowId_param", vars.get("$param.ObjectRowId_param"))
.addParameter("ObjectType_param", vars.get("$param.ObjectType_param"))
.fields(["#UID", "CONTACT_ID", "CONTACT_ID.displayValue", "CONTACTROLE", "DEPARTMENT", "ICON", "IMAGE",
"MEMBERROLE", "MEMBERROLE.displayValue", "OBJECT_ROWID", "OBJECT_TYPE",
"OBJECTMEMBERID", "ORG_ORGID", "ORGANISATION_NAME", "PERSON_FIRSTNAME", "PERSON_FULL_NAME",
"PERSON_LASTNAME", "PERSON_PERSID", "PERSON_SALUTATION", "PERSON_TITLE", "POSITION", "TARGETCONTEXT",
"recordType", "MST_MEMBERROLE", "PERSON_ATTR_LOYALTY"]);
if (idValues)
{
memberLoadingConfig.uids(idValues);
}
if (filter && filter.filter != null)
{
memberLoadingConfig.filter(JSON.stringify(filter.filter));
}
var memberRows = entities.getRows(memberLoadingConfig);
memberRows = memberRows.map(function(row)
{
return [
row["#UID"],
row["OBJECTMEMBERID"],
row["CONTACT_ID"],
row["CONTACT_ID.displayValue"],
row["CONTACTROLE"],
row["DEPARTMENT"],
row["ICON"],
row["IMAGE"],
row["MEMBERROLE"],
row["MEMBERROLE.displayValue"],
row["OBJECT_ROWID"],
row["OBJECT_TYPE"],
row["ORG_ORGID"],
row["ORGANISATION_NAME"],
row["PERSON_FIRSTNAME"],
row["PERSON_FULL_NAME"],
row["PERSON_LASTNAME"],
row["PERSON_PERSID"],
row["PERSON_SALUTATION"],
row["PERSON_TITLE"],
row["POSITION"],
row["TARGETCONTEXT"],
row["recordType"],
row["MST_MEMBERROLE"],
row["PERSON_ATTR_LOYALTY"]
];
});
if (Utils.isNullOrEmpty(idValues) || memberRows.length === 0)
{
if (vars.get("$param.ObjectType_param") == "Salesproject" && vars.get("$param.ObjectRowId_param") != null)
{
var orgContactId = newSelect("SALESPROJECT.CONTACT_ID")
.from("SALESPROJECT")
.where("SALESPROJECT.SALESPROJECTID", "$param.ObjectRowId_param")
.cell();
var districtLoadingConfig = entities.createConfigForLoadingRows()
.entity("DistrictResponsible_entity")
.provider("OrganisationResponsibles")
.addParameter("OrgUid_param", orgContactId)
.fields(["#UID","DISTRICTRESPONSIBLEID", "DISTRICT_ID", "EMPLOYEE_CONTACT_ID",
"EMPLOYEE_CONTACT_ID.displayValue", "USER_EDIT", "USER_NEW",
"departmentAttributeName", "DATE_EDIT", "DATE_NEW"]);
var districtRows = entities.getRows(districtLoadingConfig);
districtRows = districtRows.map(function(row)
{
return [
row["#UID"],
row["DISTRICTRESPONSIBLEID"],
row["DISTRICT_ID"],
row["EMPLOYEE_CONTACT_ID"],
row["EMPLOYEE_CONTACT_ID.displayValue"],
row["USER_EDIT"],
row["USER_NEW"],
row["departmentAttributeName"],
row["DATE_EDIT"],
row["DATE_NEW"]
];
});
}
var responsibleUids = [];
if(districtRows != undefined)
{
districtRows.forEach(function(row){
responsibleUids.push(row[3]);
});
var loadingConfPers = entities.createConfigForLoadingRows()
.entity("Person_entity")
.uids(responsibleUids)
.fields(["ORGANISATION_ID", "ORGANISATION_NAME", "CONTACTROLE", "POSITION",
"FIRSTNAME", "LASTNAME", "SALUTATION", "TITLE", "PERSONID", "CONTACTID"]);
var persRowsMap = {};
entities.getRows(loadingConfPers).forEach(function(item) {
persRowsMap[item["CONTACTID"]] = item;
});
var persRows = [];
responsibleUids.forEach(function(uid) {
persRows.push(persRowsMap[uid]);
});
persRows = persRows.map(function(row){
return [row["SALUTATION"], row["TITLE"], row["FIRSTNAME"], row["LASTNAME"],
row["ORGANISATION_NAME"], row["ORGANISATION_ID"], row["CONTACTROLE"],
row["POSITION"], row["PERSONID"]];
});
districtRows.forEach(function(row, counter){
memberRows.push(
[row[0],
null,
row[3],
row[4],
persRows[counter][6],
row[7],
"VAADIN:GLOBE",
"TEXT:" + row[4].substring(row[4].indexOf(" ", 0)+1, row[4].length),
"70cbad1b-eac6-4369-ba50-4946e0fbcb3a",
translate.text("District Responsible"),
vars.get("$param.ObjectRowId_param"),
vars.get("$param.ObjectType_param"),
persRows[counter][5],
persRows[counter][4],
persRows[counter][2],
row[4],
persRows[counter][3],
persRows[counter][8],
persRows[counter][0],
persRows[counter][1],
persRows[counter][7],
null,
"DistrictResponsible",
"",
(new AttributeRelationQuery(
row[3],
$AttributeRegistry.loyalty()
).includeDisplayValue().getSingleAttribute() || {displayValue: ""}).displayValue
]);
});
}
}
result.object(memberRows);
\ No newline at end of file
import("system.vars");
import("system.entities");
//While there is no need to implement the insert or update process the delete process needs to be specified because the
//contexts viewmodeProvider for the editView only affect insert and update (delete has no view associated)
//let's do the db-record container the job to remove the record (additional district records can never be removed):
var rowData = vars.get("$local.rowdata");
var memberId = rowData["OBJECTMEMBERID.value"];
if (memberId)
{
var config = entities.createConfigForDeletingRows().entity("Member_entity").uid(memberId);
entities.deleteRow(config);
}
else
throw new Error("Member_entity: Could not delete member entity because the given OBJECTMEMBERID was empty.");
//No insert code, because it is done in via the contexts viewmodeProvider for the editView
\ No newline at end of file
//No update code, because it is done in via the contexts viewmodeProvider for the editView
\ 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