How to insert values of process in database

Hello,
I am currently working on camunda modeler and I want to retrieve the characteristics of the process (Name, id, …) that the user will enter to insert it in a Database.
For example for this process, I want to get the name of the process “processtest” that the user had enter.

In your opinion how i can do this?

Get the data from the bpmn-file that is saved by the user (It’s XML).

Here is a library to get the data easily with java: https://docs.camunda.org/manual/7.7/user-guide/model-api/bpmn-model-api/

Hope this helps, Ingo

Thanks for your response.

My probleme is when i add new property like "coût"in the panel it’s doesn’t appear in the XML.
what’s i will add to xml editor to have the value of my new property.

Hi @BELLAL

are you developing a modeler plugin?
Take a look at https://github.com/bpmn-io/bpmn-js-examples/tree/master/properties-panel-extension
It is important to add the moddleExtension, that bpmn-js knows the new variables are valid.
Take a closer look at the magic.json file in the descriptors folder.

regards,
Dominik

Hi,
what i need is when i enter value in the field i need to get this value and insert it in database.
for example when i enter 30 in field “coût” i need to get this value and insert it in database.
that’s my code in the field implementation/costProp.js

'use strict';

var entryFactory = require('../../../../factory/EntryFactory'),
    isIdValid = require('../../../../Utils').isIdValid,
    getBusinessObject = require('bpmn-js/lib/util/ModelUtil').getBusinessObject;

var ScenarioHelper = require('../../../../helper/ScenariosHelper'),
    getScenarioById = ScenarioHelper.getScenarioById,
    getMetricsByElementId = ScenarioHelper.getMetricsByElementId;
var debug = require('debug')('cost-props');
module.exports = function(element, options) {

  options = options || {};

  var id = options.id,
      reference = options.reference,
      label = options.label;

  var costEntry = entryFactory.textField({

    id: id || 'cost',
    label: label || 'Coût',
    modelProperty: 'cost',
    reference: reference,
    editable: true,
    get: function(element, node) {

         return {cost: 12 };
  },
    set: function(element, values, node) {
  }

  });

  return [ costEntry ];

};

this code return automatically 12 in the “Coût” field, like the follow picture:

Hi @BELLAL

For the externalTopic the get method looks like the following:

get: function(element, node) {
      var bo = getBusinessObject(element);
      return { externalTopic: bo.get('camunda:topic') };
    }

In your case you should do something like:

 get: function(element, node) {
          var bo = getBusinessObject(element);
          return { cost: bo.get('custom:cost') };
        }

But I think before that you have to define a namespace in your descriptor json file, extend the bpmn:UserTask and add the property cost.

{
  "name": "custom",
  "prefix": "custom",
  "uri": "http://custom",
  "xml": {
    "tagAlias": "lowerCase"
  },
  "associations": [],
  "types": [
    {
      "name": "YourUserTask",
      "extends": [ "bpmn:UserTask" ],
      "properties": [
        {
          "name": "cost",
          "type": "String",
          "isAttr": true
        }
      ]
    }
  ]
}

In my point of view you have to do that. If not the variable is not added to xml.
Take a look at how that is done in the example I posted before :slight_smile:

regards,
Dominik