Community

Connect with us and enhance your M-Files experience using Unitfly Toolkit for M-Files. Here’s how to get started.

Notifications
Clear all

[Solved] Select date from indirect reference when there are multiple objects.

0
Topic starter

Need to copy Document Date on to a Case object from a related document referenced in a specific lookup property. Used a rule with indirect reference like {document.document date}

This works fine when there is only one document in the lookup property which is the case in most instances. However, sometimes there may be two documents in that lookup property.
The rule probably will yield a double result like 24-03-2024;25-03-2024 which obviously won't fit into the designated date property. Therefor the date property will remain empty.

Is there a trick that might enable the rule to select only the first (or last) result and thereby deliver valid input to the date property?

1 Answer
0

Hi @karl-lausten,

there is a bypass you can use to achieve the wanted functionality. You can set the value {document.document date} to additional text property on the Case object and then use the Auto Properties

module to extract the first date with regex and parse the value of text property to date property. Once this process is finished you can delete the value from the temporary text property.

Here is the configuration assuming you already set the "Text property" with value {document.document date} (which in your case would be 24-03-2024;25-03-2024):

image

We are using the following Auto-properties expression:

<<REGEX('%PROPERTY_{PD.TextProperty}%','.+?(?=;)')>>

with regex `.+?(?=;)`which extracts string until the semicolon which transforms 24-03-2024;25-03-2024 into 24-03-2024. 

Then we need to configure the rule which will use the DATE auto properties expression to extract the date from the string and save it to the date property. 

image

We are using Auto-properties expression:

<<DATE('%PROPERTY_{PD.TextProperty}%','MM/dd/yyyy'>>

to parse the Date from the text property and save it to the "Date property". In this case format on the Server that this rule is tested is "MM/dd/yyyy" You need to set up the format accordingly to your Server date format so that the date is successfully inserted. 

Auto-properties module also support complex expressions meaning you can resolve multiple expression inside of one. This can be achieved with one auto properties rule saving directly to "Date property" but I have split the rule in two for the sake of explanation. Your Auto-properties expression would be:

<<DATE('<<REGEX('%PROPERTY_{PD.TextProperty}%','.+?(?=;)')>>','MM/dd/yyyy'>>

I am attaching

which resembles the two rules described.

Answer