PhenixID

PSD1155 – Calculate a value in Identity Manager

Summary

This PhenixID Solution Document (PSD) is written for PhenixID Identity Manager (IM) 5.4.1 or later.

With this filter you can make calculations using numerical values from up to 10 text fields in the form. The result of the calculation will be placed in another text field.

Download filter

Click the following link PSD1155 to download the filter.

Add filter to IM WEB

Add calculateFilter.js to the following file path:
[IM root folder]/customer/extension/web/js/psd
If the /js/psd folder does not exist, then create one.

Add CalculateFilterProvider.class to the following file path:
[IM root folder]/customer/extension/class/psd
If the /psd folder does not exist, then create one.
Restart Identity Manager.

Configure the filter in a form

  1. Open IM Configurator
  2. Open the form where you like to add the filter.
  3. Create a text field control where the calculated value should be placed, here called resultControl
  4. Create a text field control where one of the numerical values should be entered, here called numericalControl
  5. Click External Filter on the numericalControl
  6. Click no filter assigned under Key or Post
  7. In JavaScript type: js/psd/calculateFilter.js
  8. In Function type: calculate
  9. Under parameters, click Variable
  10. Select the control where the result should be placed, in this case the resultControl
  11. Click String
  12. In the String dialog box, enter the calculation you want to make, using XX for any text field from the form
  13. Click String
  14. In the String dialog box, enter the number of decimals you want in the result value
  15. Click Variable, and select the text field to use for the XX value in the calculation, in this case the numericalControl
  16. Repeat no 15 for as many numerical text fields as you have in the calculation. Make sure to enter the text fields in the same order as they should be used in the calculation.
  17. Save the form and test your form

Example

In a form there is one text field called ‘salary’ where the monthly salary is entered (see screenshot below how it looks in the browser). There is also one text field called ‘workTime’ where the percentage of working is entered. If the employee works full time, 100 is entered in ‘workTime’. If the employee works half time, 50 is entered in ‘workTime’.

A third text field called ‘calculatedSalary’ is meant to show the calculation of how much the employee will get in salary, depending of his/her work time. The calculated salary will be shown with 2 decimals.

The calculation should be made when the administrator leaves the field ‘salary’ or the field ‘workTime’, therefore the filter is entered in Post event for both those controls.

The configuration parameters, looking the same for both ‘salary’ and ‘workTime’:

1. $calculatedSalary
2. "XX*XX*0.01"
3. "2"
4. $salary
5. $workTime

Example from Configurator:

Will present the following on IM Web:

So the value in Salary will be multiplied with the value in Worktime and then multiplied with 0.01, to display the value in Calculated Salary.


DISCLAIMER
Information provided in this document is for your information only. PhenixID makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.

The origin of this information may be internal or external to PhenixID. PhenixID makes all reasonable efforts to verify this information.

PhenixID - support.phenixid.se