Hi there,
I want to use attributes of the bpmn which are already defined in the bpmn.json-file.
For testing I attached the following new action to the ContextPadProvider (resources attribute to Task):
'resource':{
group: 'edit',
className: 'icon-screw-wrench',
title: 'Set Resource',
action: {
click: function(event,element){
var result=window.prompt('Resource role of '+element.name);
if(result){
modeling.updateProperties(element,{'resources':result});
}
}
}
}
If I debug the Task the businessObject got the attribute, but if i export the diagramm to xml the property is not included.
Have i forgotten to register the “new” attribute somewhere?
The BPMN meta-model defines Activity#resources as a many property to elements of type ResourceRole. Make sure to put elements of type ResourceRole into the collection and not strings (these are returned from window.prompt(...)).
BPMN types such as ResourceRole can be created using the BpmnFactory:
// creating new resource role
var resourceRole = bpmnFactory.create('bpmn:Performer', { name: 'FooBar' });
// updating task
modeling.updateProperties(element, { resources: [ resourceRole ] });
And how do I achieve to add bpmn:PartnerRole with a Participant as ‘participantRef’-attribute. With the following code it is not rendered to xml.
var bo=element.businessObject;
var resourceRole=elementFactory._bpmnFactory.create('bpmn:PartnerRole',{'name': "AppEnsemble",'participantRef':bo});
I also tried to give them a shape via:
var PartnerRole=elementFactory._bpmnFactory.create('bpmn:PartnerRole',{'name': "AppEnsemble"});
var PartnerRoleShape=elementFactory.createShape({businessObject:PartnerRole});
modeling.updateProperties(PartnerRole,{'participantRef':bo});
Note that I do not use modeling.updateProperties(...) because definitions is not a diagram element. This is something we could support in the future. If you would like to make the assignment undoable, read this thread.