Hi, Please see the screenshot below. When error log checkbox is checked I get the projection name and set it on the error log variable text input field.
When I download the XML file Error Log Variable Name input parameter is not there. If I click on the input field then I can see it’s added to the XML file. I am just wondering if I can create the element for the input field when value get sets without typing it.
Following is the code I am using:
<>props.js
//error log variable name field
group.entries.push(
entryFactory.textField(translate,{
id: 'errorLogVariableName',
label: translate('Error Log Variable Name'),
description: translate("Specify the name of the execution variable into which errors messages are copied. e.g. <ProjectionName>_Error_Log"),
modelProperty: 'errorLogVariableName',
placeholder:"placeholder text",
hidden: function(element, node) {
// Hides this field when the current action is CALL
return !isErrorLogChecked(element);
},
get: function(element, node) {
let result = {errorLogVariableName: getProjectionName(element)+'_Error_Log'};
let bo = getBusinessObject(element, node);
let inputParameter = getInputParameterByName(bo, Constants.PRJ_ERROR_LOG_VARIABLE_PARAM);
if (inputParameter) {
let storedValue = inputParameter.get('value');
result = { errorLogVariableName: storedValue };
}
return result;
},
set: function(element, values, node) {
let bo = getBusinessObject(element, node);
let commands = [];
let inputParameter = getInputParameterByName(bo, Constants.PRJ_ERROR_LOG_VARIABLE_PARAM);
//if input parameter is not present then create otherwise update it
if (!inputParameter) {
commands = createInputParameterByName(
element,
bpmnFactory,
Constants.PRJ_ERROR_LOG_VARIABLE_PARAM,
values.errorLogVariableName
);
} else {
commands.push(
cmdHelper.updateBusinessObject(element, inputParameter, {
value: values.errorLogVariableName || undefined
})
);
}
return commands;
}
})
);
<>Helper.js
export function getProjectionName(element) {
let bo = getBusinessObject(element);
let inputParameter = getInputParameterByName(bo, Constants.PROJECTION_NAME_PARAM);
return inputParameter && inputParameter.get('value');
}
export function createInputParameterByName(element, bpmnFactory, parameterName, parameterValue, isMapParameter) {
let commands = [];
let bo = getBusinessObject(element);
let extensionElements = getExtensionElement(element);
let inputOutput = inputOutputHelper.getInputOutput(bo, false);
//create extension elements if not present
if (!extensionElements) {
extensionElements = elementHelper.createElement(
'bpmn:ExtensionElements',
{ values: [] },
bo,
bpmnFactory
);
commands.push(cmdHelper.updateProperties(element, { extensionElements: extensionElements }));
inputOutput = elementHelper.createElement(
'camunda:InputOutput',
{ inputParameters: [] },
extensionElements,
bpmnFactory
);
commands.push(
cmdHelper.addAndRemoveElementsFromList(
element,
extensionElements,
'values',
'extensionElements',
[inputOutput],
[]
)
);
//create default input action parameter if not present
let actionParameter = getInputParameterByName(bo, Constants.PROJECTION_ACTION_PARAM);
if (!actionParameter && parameterName !== Constants.PROJECTION_ACTION_PARAM) {
actionParameter = elementHelper.createElement(
'camunda:InputParameter',
{ name: Constants.PROJECTION_ACTION_PARAM, value: 'READ' },
inputOutput,
bpmnFactory
);
commands.push(
cmdHelper.addElementsTolist(element, inputOutput, 'inputParameters', [actionParameter])
);
}
}
let inputParameter = getInputParameterByName(bo, parameterName);
if (!inputParameter) {
let properties = isMapParameter ?
{ name: parameterName} :
{ name: parameterName, value: parameterValue };
inputParameter = elementHelper.createElement(
'camunda:InputParameter',
properties,
inputOutput,
bpmnFactory
);
commands.push(cmdHelper.addElementsTolist(element, inputOutput, 'inputParameters', [inputParameter]));
}
if (isMapParameter) {
if (!inputParameter.definition) {
inputParameter.definition = elementHelper.createElement(
'camunda:Map',
{ value: undefined, entries: [] },
inputParameter,
bpmnFactory
);
commands.push(
cmdHelper.updateBusinessObject(element, inputParameter, {
definition: inputParameter.definition
})
);
}
//create values input field
let newEntry = elementHelper.createElement(
'camunda:Entry',
{ key: parameterValue, value: undefined },
inputParameter.definition,
bpmnFactory
);
commands.push(
cmdHelper.addElementsTolist(element, inputParameter.definition, 'entries', [newEntry])
);
}
return commands;
}
Any help would be truly appreciated it.