Obtain Stakeholder information

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples >

Obtain Stakeholder information

When you want to handle Stakeholder's information, being related to the currently logged user or other users, you may rely on new methods provided by the Bizagi rules API.

 

Consider that one same user can belong to one or more stakeholders at the same time, or none at all.

Therefore and through the methods provided by Bizagi rules API, you will be able to create expressions that for instance allow you to:

 

Obtain the information related to a user's stakeholder configuration (a reference to the stakeholder instance), by parting from the user's Id and while specifying the type of stakeholder you want to fetch information from.

 

Obtain all the users (an array list) who are mapped/belong to a given stakeholder.

 

Obtain information relating a Stakeholder, given a user

The following function allows you to obtain the Stakeholder object given a user, and navigate it using XPath.

 

CHelper.GetStakeholdersByUser(UserId, "StakeholderName");

 

To navigate using Xpath, the easiest thing is to declare a variable and use the getXPath and setXPath functions. However you can also perform the following

 

CHelper.GetStakeholdersByUser(UserId, "StakeholderName").getXPath("attributename")

 

Property

Description

UserId

The function requires a user Id to evaluate the user and the Stakeholder name.

StakeholderName

A String with the name of the required Stakeholder.

attributename

The name of the attribute within the stakeholder to be obtained

 

 

Example

In an Emergency room we need to allocate the Doctor who attended an emergency, to the next task, and we need to save his/her specialty in an attribute.

The following is the process' data model.

 

Stakeholder1

 

 

The following is the expression to obtain the Stakeholder's object and navigate it.

 

Stakeholder2

 

 

var Doc = CHelper.GetStakeholdersByUser(Me.Case.WorkingCredential.UserId, "Doctor");

<Triage.Attendingdoctor> = Doc;

var speciality =  Doc.getXPath("speciality");

 

Obtain all users given a Stakeholder

The following function allows you to obtain all the users related to a Stakeholder object. This returns an array that can be navigated

 

CHelper.GetUsersForStakeholder("StakeholderName");

 

 

Property

Description

StakeholderName

A String with the name of the required Stakeholder.

 

In an emergency room we need to obtain a list of all the users that are Doctors and save their names.

         

var allDoctors = CHelper.GetUsersForStakeholder("Doctor")

var listName="";

for(var i=0; i< allDoctors.Count;i++)

{

 var fullName = allDoctors[i].getXPath("associatedUser.fullName");

 listName=fullName+listName;

}