The Field Calculator can be used to perform various tasks on MagNews.
Here we show you how to set a Language
field based on the values in the Country
field.
Scenario
In a database, we want to perform a calculation to set the language
field according to the following rules:
- If the
Country
field contains the value Italy, thelanguage
field will be set to ITA; - If the
Country
field contains the value France, thelanguage
field will be set to FRA; - If the
Country
field contains the value England, thelanguage
field will be set to ENG; - If the
Country
field contains the value Russia, thelanguage
field will be set to ENG; - If the
Country
field contains no value or a value different from the above, thelanguage
field will be set to ENG.
Operation configuration
Access Field Calculator by following the path:
Management > Field Calculator
You will be presented with the main page of the Field Calculator containing the list of already configured operations.
Click on the "New Calculation" button in the top right to access the first configuration page of the operation.
Choose the Language
field from the dropdown menu.
The result of the operation will be written in this field.
Click on Save in the top right corner of the page.
The operation configuration page will be displayed.
In the Narrow target section, select the database whose contacts will be affected by the calculation by applying a specific condition.
In the Expression section, enter the 4 previously described conditions and the actions to take if they are verified.
To add a condition and the corresponding action, click on Add Condition.
In the If column, write the condition to verify the value of the COUNTRY
field:contact.values.COUNTRY EQ 'Italy'
where COUNTRY
is the ID of the database field to be verified and Italy
is the value to be checked.
Fill in the four cells of the If column, the Then Assign Value column, and complete the value of the Otherwise field (where to enter the value to be written in the field if none of the conditions are verified).
Complete the configuration by clicking on Save and perform a test to ensure there are no errors or issues.
Click on the Preview for a Contact button.
In the window that appears, enter the ID of a contact belonging to the database defined in the Narrow target section and click the Preview for a Contact button again.
The result of the operation on the selected contact will be displayed, or alternatively, an error message.
Scheduling
After configuring the operation, proceed to define its Scheduling.
If you select the value On Request in the Scheduling Type, the operation will be executed by clicking on the "Launch Calculation" button. Otherwise, by changing the value of this field to Daily, Weekly, or Monthly, the calculation will be executed according to the schedule you configure.