I am creating a custom space planner application in the application i want the behaviour in such a way i can allocate a single room to multiple users, how can i achieve this like when we assign an occupant to any unit the unit stores the name of the occupant in Known As field, the occupant stores the unit id of the unit allocated to them etc. So what all steps will i be performing for allocation more than one occupant to the room. I have written the following code for the assigning of a single occupant to the room:
var unitQuery=unitsLayer.createQuery();
unitQuery.where = `NAME = '${globalUnitName}'`;
unitQuery.outFields = ["*"];
var query= occupantsLayer.createQuery();
query.where = `KNOWNAS= '${name}'`;
query.outFields = ["*"];
occupantsLayer.queryFeatures(query).then(function(result){
var occupant=result.features[0];
console.log("occupant data",occupant);
unitsLayer.queryFeatures(unitQuery).then(async function(res){
var feature=res.features[0];
console.log("unit data",feature);
feature.attributes.ASSIGNMENT_TYPE="office";
feature.attributes.KNOWNAS=name;
feature.attributes.EMAIL=occupant.attributes.EMAIL;
feature.attributes.JOB_TITLE=occupant.attributes.JOB_TITLE;
occupant.attributes.UNIT_ID=feature.attributes.UNIT_ID;
occupant.attributes.LEVEL_ID=feature.attributes.LEVEL_ID;
occupant.geometry.x=feature.geometry.centroid.x;
occupant.geometry.y=feature.geometry.centroid.y;
console.log("oc after",occupant);
console.log("un after",feature);
var occupantUpdate=[{
attributes:occupant.attributes,
geometry:occupant.geometry
}]
console.log("update occupant",occupantUpdate);
await LayerApplyEdits(occupantsLayer,{ updateFeatures:occupantUpdate})
var updates = [{
attributes: feature.attributes,
geometry: feature.geometry
}];
await LayerApplyEdits(unitsLayer,{updateFeatures:updates});
What all changes do i have to make for the assigning part so that i can allocate more than one occupant to a single unit?