Articles on: Developers
This article is also available in:

Add initiator email automatically

The following script will help you obtain the email of the logged user and store it into a ‘Logged user’ field. This is particularly useful when you want to use this email for other purposes.

How to do it



Create an email type field in your form. We will call it ‘Logged user’.



Click to the ‘Visibility settings and Scripts’ button.



Navigate to the ‘Scripts’ tab and select the Initiation task in your workflow.



Copy there the following script:

function initScript(){
// Hide Logged user field
Flokzu.setHidden([[Logged user]]);
// Obtain Logged user
var userLogin = Flokzu.currentUser();
// Set Logged user field
Flokzu.setFieldValue([[Logged user]],userLogin);
}
Flokzu.onInit(initScript);


Useful case



Suppose that after the initiator submits the initial document, you want to assign him/her an Approver automatically, because different users have different approvers within your organization. To do this, simply follow these steps:

Create a database with two columns: Email and Approver. In the first column you will enter the email addresses of all the users whose documents will need approval. In the second column you will enter the email addresses of all the approvers in your organisation, taking special care to list them right next to the person they need to approve.



Create a combo box ("Logged user") to save the email of the user who is submitting the form.

Create an email field ("Approver") to save the approver email (required).

Follow steps 2-4 above on how to obtain the logged user email automatically.

Edit the settings of the combo box and select the Email column as Bound value.



Navigate to the Trigger tab and set up the following trigger: select the Approver column from your database as Column heading and the Approver field as Field. The result is that once that the Logged user is retrieved from your database, the Approver will be retrieved automatically and saved in the corresponding field.

Updated on: 10/01/2019

Was this article helpful?

Share your feedback

Cancel

Thank you!