I ran into the following problem while writing a formula. I boiled it down to the following simple example:
This works correctly:
Set( data, "regexdata" );
Set( regex, Match( data, "regex(?<h>.*)" ) );
Set( data, regex.h );
The global variable 'data' is assigned a text value, and after that the regular expression is used to update the value. (You could demonstrate this by displaying the value of the 'data' variable on a label).
However, if I add an extra line :
Set( data, "regexdata" );
Set( rawdata, data );
Set( regex, Match( data, "regex(?<h>.*)" ) );
Set( data, regex.h );
The editor starts throwing errors, indicating incompatible types.
@iAm_ManCat - Thanks for the code. It's useful to see how setting a interim variable fixes the problem. It's extra evidence that this is indeed a bug.
Set( Data2, regex.h );
Set( Data, Data2 )
I also now notice that wrapping Text around regex.h removes the error.
@MrNappa - thanks for sharing this problem. Hopefully, Microsoft will fix this. If this sort of problem forces you to revert to a previous version, it sounds serious. I'm glad you didn't lose much work though.
Yeah, thanks for the suggestion. Actually the extra variable is not necessary but I was having a bit of trouble with my regular expression so I added the extra variable to catch the 'raw' value of the string being regexed so I could debug it better. That's when I ran into this.
Hi,
Yes, I agree this is a bug with how the string within the Match value is being read against other string values - you can use a second variable to get around it though:
Set( Data,"regexdata" );
Set( rawdata, Data );
Set( regex, Match( Data, "regex(?<h>.*)" ) );
Set( Data2, regex.h );
Set( Data, Data2 )
Cheers,
Sancho
Yeah, I'm pretty sure it's a bug too, the automatic type detection algorithm can be a bit off at times. The app where I first experienced this is a lot more complex, and I had the editor freeze on me in the formula that contained a structure similar like this. After that the app failed to load, so I had to revert it to a previous version 😅. (luckily not much was lost, this was the only formula I had been working on since the last stable save).
Hi @MrNappa
Unfortunately, I don't know what the cause of this problem is. "regexdata" and regex.h are both of type string, so the syntax should be correct. I think there might be a bug in the editor or PowerApps.
Perhaps someone else might be able to look at this and spot what's wrong?
No, this example was done on a new empty blank canvas app, I only added a button and put this formula in the 'OnSelect' handler.
Hi @MrNappa
Have you used the variable rawdata elsewhere in your app and assigned it a data value that isn't of type string? That would be a possible cause of the problem.
Can you rename rawdata to rawdata2 and see if the problem goes away? If so, that would confirm the hypothesis.
Set( data, "regexdata" );
Set( rawdata2, data );
Set( regex, Match( data, "regex(?<h>.*)" ) );
Set( data, regex.h );
WarrenBelz
146,635
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional