Adding Custom Attribute to BPMN Elements I used this solution and added attribute. When I want to update the label I update the code section below ,
this.drawShape = function (parent, element) {
var attrs = {
fill: getFillColor(element),
stroke: getStrokeColor(element)
};
var rect = drawRectForTask(parent, element, attrs)
renderEmbeddedLabel(parent, element, 'center-middle');
attachTaskMarkers(parent, element);
//renderExternalLabel(parent, element);
var text= "";
var role= getExtension( getSemantic(element), "hbk:Role");
if(role)
{
text= role.Name
}
renderCustomLabel(parent,text,element);
return rect;
};
function getExtension(element,type) {
if (!element.extensionElements) {
return null;
}
return element.extensionElements.get('values').filter(function (e: any) {
return e.$instanceOf(type);
})[0];
}