Unitfly Toolkit for M-Files logo color

Auto properties module extends property concatenation expression language with additional macros for text formatting and translation, date manipulations and numeric calculations. When property concatenation expression contains any of the supported macros, it is automatically converted into calculated property and its new value is calculated.

Macro Expressions #

  1. Date Part Expressions
  2. Date Format Expressions
  3. Date Diff Expressions
  4. Date add parsers
  5. Filter Lookups Expression
  6. Format Lookups Expressions
  7. Math Expressions
  8. Ternary Operator Expressions
  9. Text transform parser
  10. Translation Expressions
  11. Regex parse
  12. File metadata parse
  13. Combining multiple Macros

1. Date Part Expressions #

Expressions

Description

<<YEAR>>	

Gets current year

<<MONTH>>

Gets current month

<<DAY>>

Gets current day of month

<<HOUR>>

Gets current hour

<<MINUTE>>

Gets current minute

<<SECOND>>

Gets current second

<<YEAR(<date>)>>

Gets the year part of the specified date property or expression.
Eq. <<YEAR(%PROPERTY_20%)>>

<<MONTH(<date>)>>

Gets the month part of the specified date property or expression.
Eq. <<MONTH(%PROPERTY_20%)>>

<<DAY(<date>)>>

Gets the day part of the specified date property or expression.
Eq. <<DAY(%PROPERTY_20%)>>

<<HOUR(<date>)>>

Gets hour part of the specified date property or expression.
Eq. <<HOUR(%PROPERTY_20%)>>

<<MINUTE(<date>)>>

Gets the minute part of the specified date property or expression.
Eq. <<MINUTE(%PROPERTY_20%)>>

<<SECOND(<date>)>>

Gets the second part of the specified date property or expression.
Eq. <<SECOND(%PROPERTY_20%)>>

Example #
Property NameProperty IDProperty ValueData Type
StartDate42December 24, 2020Date

Input: <<YEAR(%PROPERTY_42%)>>

Result: 2020

Input: <<MONTH>>

Result: 12

2. Date Format Expressions #

Expression

Description

<<NOW>>

Gets current date and time, formatted according to the default System account format.

<<TODAY>>

Gets current date, formatted according to the default System account format.

<<NOW(<format>)>>

Gets current date and time, formatted according to the specified custom format.

<<TODAY(<format>)>>

Gets current date, formatted according to the specified custom format.

<<DATE('<property>','<format>')>>

Gets value of date property or expression, formatted according to the specified custom format.
Eq. <<DATE(‘%PROPERTY_20%’,’yyyy-MM-dd’)>>

Format specifiers that can be used in these expressions are the default C# format specifiers, as specified in https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings.

Example #
Property NameProperty IDProperty ValueData Type
StartDate42December 24, 2020Date
Now = current date = eg. April 1st 20200

Input: <<DATE(‘%PROPERTY_42%’,’MM/dd/yyyy’)>>

Result: 12/24/2020

Input: <<NOW(ddMMyy)>>

Result: 010420

3. Date Diff Expressions #

Expression

Description

<<DATEDIFF('<date>','<date>','<units>')>>

Gets difference between two date properties or expressions.
Units can be any of the following:
• YEARS
• MONTHS
• WEEKS
• DAYS
Eq. <<DATEDIFF(‘<<TODAY>>’, ‘%PROPERTY_20%’, ‘DAYS’)>> calculates age of any object (difference between current date and document’s creation date).

Example #
Property NameProperty IDProperty ValueData Type
StartDate42December 24, 2020Date
EndDate50March 2, 2021Date
Now = current date = eg. April 1st 20200

Input: <<DATEDIFF(‘%PROPERTY_42%’,’%PROPERTY_50%’,’DAYS’)>>

Result: 41

Input: <<DATEDIFF(‘<<NOW>>’,’%PROPERTY_50%’,’DAYS’)>>

Result: 308

4. Date add parsers #

Expression

Description

<<DATEADD('<date>','<value>','<units>')>>

Adds unit of time to the specified date.
Units can be any of the following:
• YEARS
• MONTHS
• WEEKS
• DAYS
Eq. <<DATEADD(‘<<TODAY>>’, ‘%PROPERTY_20%’, 7′,’DAYS’)>> add 7 days to property date (difference between current date and document’s creation date).

Example #
Property NameProperty IDProperty ValueData Type
SubmittedDate42November 1, 2021Date

Input: <<DATEADD(%PROPERY_20%’,’7′,’DAYS’)>>

Result: 17.01.2021

5. Filter Lookups Expression #

Expression

Description

<<FIRST('%PROPERTY_ID%')>>

Selects the first lookup from multi select lookup property.

<<LAST('%PROPERTY_ID%')>>

Selects the last lookup from multiselect lookup property.

Note: For older M-Files versions where %PROPERTY_ID%.%PROPERTY_ID% syntax is not supported, property relations to second, third, etc. level can be achieved like below.

<<FIRST('%PROPERTY_ID%','%PROPERTY_ID%',...)>>

<<LAST('%PROPERTY_ID%','%PROPERTY_ID%',...)>>

Example #
Property NameProperty IDProperty ValueData Type
Contract60NDA – AlanChoose from list
Years752018,2019,2020Choose from list (multi-select)

Input: <<FIRST(‘%PROPERTY_75%’)>>
Result: 2018

Input: <<LAST(‘%PROPERTY_60%’.’%PROPERTY_75%’)>>
Result: 2020

Input: <<LAST(‘%PROPERTY_60%’,’%PROPERTY_75%’)>>
Result: 2020

6. Format Lookups Expressions #

Expression

Description

<<FORMATLOOKUPS('<separator>','%PROPERTY_ID%')>>

Formats selected multiselect lookup property as text.

Note: For older M-Files versions where %PROPERTY_ID%.%PROPERTY_ID% syntax is not supported, property relations to second, third, etc. level can be achieved like below.

<<FORMATLOOKUPS('<separator>','%PROPERTY_ID%',...)>>

Example #
Property NameProperty IDProperty ValueData Type
Contract60NDA – AlanChoose from list
Years752018,2019,2020Choose from list (multi-select)

Input: <<FORMATLOOKUPS(‘;’,’%PROPERTY_75%’)>>
Result: 2018;2019;2020

Input: <<FORMATLOOKUPS(‘n’,’%PROPERTY_60%.%PROPERTY_75%’)>>
Result: 201820192020

Input: <<FORMATLOOKUPS(‘n’,’%PROPERTY_60%’,’%PROPERTY_75%’)>>
Result: 201820192020

7. Math Expressions #

Expression

Description

<<SUM('<number>','<number>',…)>>

Sums numeric properties or expressions.

<<SUB('<number>','<number>',…)>>

Subtracts numeric properties or expressions.

<<MUL('<number>','<number>',…)>>

Multiplies numeric properties or expressions.

<<DIV('<number>','<number>',…)>>

Divides numeric properties or expressions.

<<AVG('<number>','<number>',…)>>

Calculates average of numeric properties or expressions.

<<MIN('<number>','<number>',…)>>

Calculates minimum of numeric properties or expressions.

<<MAX('<number>','<number>',…)>>

Calculates the maximum of numeric properties or expressions.

Property NameProperty IDProperty ValueData Type
Price661001Real
Discount (%)6910Number (integer)
Example #

Input: <<SUM(‘%PROPERTY_66%’,’%PROPERTY_66%’)>>
Result: 2002

Input: <<SUB(‘%PROPERTY_66%’,'<<MUL(‘%PROPERTY_66%’,'<<DIV(‘%PROPERTY_69%’,’100′)>>’)>>’)>>
Calculation: 1001- (1001 x (10/100))
Result: 900,9

8. Ternary Operator Expressions #

Expression

Description

<<'<text>' <operator> ' <text>'? '<text>' : '<text>'>>

Calculates the value of a given ternary expression (IF-THIS-THAN-THAT operation).
Operator can be any of the following:
• !=
• >=
• <=
• >
• <
• =
Eq: Expression <<‘%PROPERTY_1156%’>=’18’?’true’:’false’>> could be used in order to automatically set IsAdult property from Age property.

Example #
Property NameProperty IDProperty ValueData Type
Priority1039HighChoose from list
Project1038Project TestChoose from list
TaskName1040Learn MacroText
Adult1050True/FalseBoolean
Age115621Number (integer)

Request

If property (Project) is empty, then don’t show it

Input

<<'%PROPERTY_1038%'=''?'%PROPERTY_1040%':'%PROPERTY_1038% - %PROPERTY_1040%'>>

Result: Project is empty

Learn Macro

Result: Project is not empty

Project Test – Learn Macro

Request

If property Priority is High, then show it, else don’t

Input

<<'%PROPERTY_1039%'='High'?'%PROPERTY_1039% - %PROPERTY_1040%':'%PROPERTY_1040%'>>

Result: Priority is High

High – Learn Macro

Result: Priority is not High

Learn Macro

Request

If Person is over 18 years old, he is an adult, so Adult property should be true, else false

Input

<<'%PROPERTY_1156%'>='18'?'true':'false'>>

Result

true

9. Text transform parser #

Expression

Description

<<TOUPPER('<text>')>>

Convert given text to uppercase.

<<TOLOWER('<text>')>>

Transfer given text to lowercase.

<<TOUPPERINVARIANT('text')>>

Converts given text to its uppercase equivalent using the casing rules of the invariant culture.

<<TOLOWERINVARIANT('text')>>

Converts given text to its lowercase equivalent using the casing rules of the invariant culture.

<<CONCATENATE(’<text1>’,’<text2>’)>>

Merge two or more text strings into one.

<<SUBSTRING('<text>','start','length')>>

Extract characters from a string.

Example #
Property NameProperty IDProperty ValueData Type
Name110JohnText

Input: <<TOUPPER(%PROPERTY_110%)>>
Result: JOHN

10. Translation Expressions #

Expression

Description

<<TRANSLATE('<text>')>>

Translates the given input based on language configured in the configuration panel. Language codes are defined by ISO standard: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

Example #
Language configured in configuration is German: DE
Property NameProperty IDProperty ValueData Type
Class100ContractChoose from list

Input: <<TRANSLATE(%PROPERTY_100%)>>
Result: Vertag

11. Regex parse #

Expression

Description

<<REGEX('<input>','pattern','idx'>>

Extract value using the given regex pattern.
IDX should be a positive integer, representing zero based index of matched result group to return.

12. File metadata parse #

Expression

Description

<<FILE('filename wildcard')>>

Extract only file name without the extension from file name.

<<EXTENSION('filename wildcard')>>

Extract file extension from file name.

<<FILENAMEWITHEXTENSION('filename wildcard')>>

Extract the whole file name.

Example: <<FILE(‘filename wildcard’)>> #

Property: testfile.pdf
Result: testfile

Example: <<EXTENSION(‘filename wildcard’)>> #

Property: testfile.pdf
Result: pdf

Example: <<FILENAMEWITHEXTENSION(‘filename wildcard’)>> #

Property: testfile.pdf
Result: testfile.pdf

13. Combining multiple Macros #

You can combine multiple macro expressions, by following the rules and adding macro instead of property. For example

<<DATEDIFF('<<NOW>>','%PROPERTY_50%','DAYS')>>
<<SUB('<<MONTH(%PROPERTY_50%)>>','<<MONTH(<<TODAY>>)>>'>>

Configuring Auto properties #

After you have successfully installed the application, you can start adding calculation rules in application configuration. Each property that is configured will be converted to auto calculated property. There can only exist one active (enabled) rule per single property. If multiple rules are configured for a single property, validation error message will be shown and only the first configured enabled rule will be used.

  1. Open M-Files Admin
  2. In the left-side tree view, expand the desired connection to M-Files Server.
  3. In the left-side tree view, expand the Document Vaults node.
  4. Still, in the left-side tree view, expand the vault where you installed the connector and select Configurations.
  5. Expand Other Applications
  6. Expand Extension Kit
  7. Click on Auto properties

Field Description #

FieldValueDescription
EnabledYes/NoSpecifies whether the module is in use.
Expression parsers > Date part parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Date format parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Date diff parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Date add parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Filter lookups parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Format lookups parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Math parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Ternary operator parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Text transform parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Regex parser
EnabledYes/NoSpecifies whether the parser is in use.
Expression parsers > Translation parser
EnabledYes/NoSpecifies whether the parser is in use.
Translation languageTextSpecifies language to translate into.
Expression parsers > Translation parser > Translation service
TypeMicrosoftTranslatorSpecifies type of translation service.
Security KeyTextOptional security key for translation service.
Expression parsers > Translation parser > Translations storage
TypeOne of:NoneSQL ServerOptional storage for translations. Currently, only SQL Server database can be used for this purpose. Storing translations fetched from translation service to permanent storage has two advantages:
Caching. No subsequent requests to translation service need to be made for inputs that already exist in storage.
Modification. Stored translations can be modified as appropriate.
Connection stringTextConnection string to the SQL Server database that will be used to store translations.
TableTextName of database table that will be used to store translations.
Rule groups > Group [n]
NameTextSpecifies rule group name.
Rule group > Group [n] > Rules [n] > Rule
NameTextSpecifies rule group name.
DescriptionTextOptional rule description.
EnabledYes/NoSpecifies whether the rule is in use.
Configuration modeSimple/AdvancedDisplay simple or advanced configuration options for rule.
PropertyPropertyProperty whose value will be calculated.
Recalculate propertiesYes/NoIf it set to yes, it will recalculate chosen properties when clicked Recalculate on dashboard.
Property valueTextCalculated property value expression.
Recalculate dailyYes/NoIf yes property will be recalculated between midnight and 1 am.
Business criticalYes/NoIf set to true, rule will be logged in SEQ.
Use calendar in Date functionsYes/NoExclude non working days only.
Works only for <> and <> macros.
Calendar setting sourceOne of the following:
• FromRule
• FromEnviroment
From Rule. Rule will use calendar specified on source.
FromEnvironment. Rule will use calendar specified in Environment section of Extension Kit.
Calendar aliasTextDisplayed only if From Environment is selected as Calendar setting source. Users must specify calendar alias from environment.
Rule group > Group [n] > Rules [n] > Rule > Calendar enviroment>NonWorkingDay[n]
OccurrenceOne of the following:
• Weekly
• Monthly
• Yearly
• Once
• Holiday
Specifies when the non-working days will be calculated weekly, monthly, yearly, once, or holiday.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Weekly>Date
WeekdayOne of the following:
• Monday
• Tuesday
• Wednesday
• Thursday
• Friday
• Saturday
• Sunday
Specifies which day in the week.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Monthly>DateOne of the following:
• Static
• From Vault
Static. Choose specific date for non working day.
From vault. Choose date property for non-working day
Type One of the following:
• Static
• From Vault
Static. Choose specific date for non working day.
From vault. Choose date property for non-working day.
TypeOne of the following:
• SpecificDate
• Specific Weekday
Day of monthNumber
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Monthly
Week of monthOne of the following:
• First
• Second
• Third
• Fourth
• Fifth
• Last
Which week of the month is used.
Day of weekOne of the following:
• Sunday
• Monday
• Tuesday
• Wednesday
• Thursday
• Friday
• Saturday
Which day of the week is used.
Date propertyProperty definitionDate property on Date object in vault.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Yearly
TypeOne of the following:
• Static
• From vault
Static. Choose specific date for non working day.
From vault. Choose date property for non-working day.
MonthOne of the following: January, February, March, April, May, June, July, August, September, October, November, December
Day of the week One of the following:
• Sunday
• Monday
• Tuesday
• Wednesday
• Thursday
• Friday
• Saturday
Search conditionSearch conditionSearch condition to use for finding date property on Date object in vault.
Date propertyProperty definitionDate property on Date object in vault.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Once
TypeOne of the following: • Static
• FromVault
DateDate
Search conditionSearch conditionSearch condition to use for finding date property on Date object in vault.
Date propertyProperty definitionDate property on Date object in vault.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Holiday>Date[n]
CountryOne of the following:
• GB
• HR
• SI
• PL
Select country for national holidays.
Use all holidaysYes/NoUse all national holidays as non-working days or not.
Rule group > Group [n] > Rules [n] > Rule > Calendar environment>NonWorkingDay[n]>Holiday>Date[n]>Use holidays [n]
Holiday[n]List of holidays.List of holiday specific for country which user choose in Country section.
Rule group > Group [n] > Rules [n] > Rule > Filter conditions
SearchConditionsSearch ConditionsDisplayed only if [Advanced] is selected as a Configuration Mode.
Optional additional conditions that object needs to satisfy. Conditions inside a single filter are combined with AND, while multiple filters are combined with OR operator.
Rule group > Group [n] > Rules [n] > Rule > Filter conditions
StopConditionsStop ConditionsDisplayed only if [Advanced] is selected as a Configuration Mode.
Optional stop condition. When object matches stop conditions, property is no longer calculated. Multiple stop conditions are combined with OR operator.
Rule group > Group [n] > Rules [n] > Rule > Default value
ModeOne of the following:
• No action
• Static value
• Empty value
Displayed only if [Advanced] is selected as a Configuration Mode.
Optional default value for property.
Static valueValueDisplay only if [Static value] is selected as a Default value mode.
Specifies constant expected property value.
Rule group > Group [n] > Rules [n] > Rule > Advanced settings
Expression typeOne of the following:
• Complex
• Simple
• None
Property referencing type can be used to further control expression capabilities and expansion.
Complex. Expression uses advanced functionality of placeholder editor.
Simple. Improve performance when using only top-level properties and ObjID or ObjVer keywords in expression.
None. Further improve performance if not using any properties or placeholder in expression
Time to wait (milliseconds)IntegerNumber of milliseconds to wait before executing any rule in background.
Number of retriesIntegerMaximum numbers of times COM errors are retried.
Retry IntervalIntegerNumber of milliseconds to wait between retries.

Use Cases #

Calculate how many days till contract expire #

Customer is using M-Files for contracts and document management. He would like to know how many days until the expiration of the contract (Picture 1). Customer has used “DATEDIFF” macro in Macros.

Picture 1. Contract

In Picture 2, we can see that Property „Expiring (days)“ has been populated.

Picture 2. Contract with Expiring (days) populated
Configuring Auto properties #
auto properties configuration
Picture 3. Configuration – Expiring

Track working days and non-working days when employee takes vacation #

Customer wants to track all working days in vacation period of employees.

We created Object type = Vacation in our M-Files Vault and added class Vacation Application. We used it for logging the days someone is out of office for more than one day.

Also we created a property Working days in which we want to calculate working days between start and end day of vacation. In addition, you can add what days are non-working, for precise calculation.

calculate working days with auto properties
Picture 4. Configure calculation of working days

Also, you can define that the system stops calculating holidays as working days, or simply choose the holiday that you don’t want to calculate.

auto properties feature exclude or include holidays

Picture 5. Exclude holidays

Your one-stop hub for Unitfly Toolkit for M-Files!

Unitfly Toolkit Community is live!

News and updates on our products • Frequently asked questions • Support page