I’m building my first calculation. I have two tables, Security and Group (both of which include Group ID and Group Name fields). I’ve populated all fields except Group Name in the Security table.
I’ve created a relationship between the two tables based on Group ID. Now I create a calculation based on Group Name. I’m uncertain about syntax. My calculation reads “return relation.group_name ;”. The Group Name fields are empty when displayed. Do I need to modify the properties of the Group Name field?
The calculation’s name is identical to the field, the “stored” tick box is checked but greyed out.
First: when you define a column and then setup a calculation with the same name as your column, the calculation is “stored”. That means that Servoy will populate that column for you, according to your calculation.
That is why the check is grey. The only way to make a calculation not stored is to change its name. The “stored” check is not for you to check and uncheck, but only to show you if something is stored or not.
As far as your formula is concerned, your code should read like this:
if (relation) // check if the relation is valid
{
return relation.column;
}
else
{
return null;
}
You need to make sure, that the datatypes match. If your column is of type number, your calculation shouldn’t return a character value.
In your specific case: I don’t think that the name of your relation between group and security is called “relation”. Your formula probably should read like this “security_to_groups.group_name” or something like that.