Skip to content

Venki-BPM/HEFLO-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HEFLO API

API (Application Programming Interface) to handle customizations on HEFLO BPM using NodeJS and Typescript.

Installing

Using npm:

$ npm install heflo-api

Example

Performing an action on a task transition

app.post('/OnExecute', async (request, response) => {
  try {
    // Access all data of the process instance
    let context = new Events.WorkItem.OnExecuteSequenceFlow(request);

    // Your code here

    // Finally, return unsaved data.  
    response.json(context.GetModifiedData());
  } catch (err) {
    response.status(500);
    response.send("Error executing the request, details: " + err);
  }
});

Changing the value of a field of a form

app.post('/onChanged', async (request, response) => {
  try {
    // Access all data of the process instance
    let context = new Events.WorkItem.OnChanged(request);

    // change another field
    context.WorkItem.Set("OtherField", "Field changed");

    // Finally, return unsaved data.  
    response.json(context.GetModifiedData());
  } catch (err) {
    response.status(500);
    response.send("Error executing the request, details: " + err);
  }
});

Performing the calculation of who will perform a task

app.post('/OnResourceCalculation', async (request, response) => {
  try {
    // Access all data of the process instance
    let context = new Events.WorkItem.OnResourceCalculation(request);

    // Your code here.
  
    // Finally, return list of emails
    response.json( [ "email1@mycompany.com", "email2@mycompany.com", ["name-of-department-or-group"] ] );
  } catch (err) {
    response.status(500);
    response.send("Error executing the request, details: " + err);
  }
});

Creating a new record of type Person

app.post('/OnExecute', async (request, response) => {
  try {
    // Access all data of the process instance
    let context = new Events.WorkItem.OnExecuteSequenceFlow(request);

    let person = await Person.NewAsync(context);
    person.Name = context.WorkItem.Get("name_person");
    person.Email = context.WorkItem.Get("email_person");
    // save the record using async 
    await person.SaveAsync(context);

    // No need to return modified data
    response.json("{}");
  } catch (err) {
    response.status(500);
    response.send("Error executing the request, details: " + err);
  }
});

About

Templates for customization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •