Replies: 2 comments
-
So I take the radio silence as confirmation that this isn't a pfx thing and I need to put it in front of a different team. @MikeStall can you help me find the right folks to share with? The power apps team isn't nearly as accessible as y'all. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi Charles, Sorry about the long tail to respond here. I'm wondering about a few things:
we're trying to reproduce your issue as we speak. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
OK, so I suspect that this is not entirely a PowerFX issue, but more how it is being implemented in the platform so I am only starting it as a Discussion topic - I can open an issue if folks think it should be one, or I can go nag a different team...
Background:
I am working on a Custom Page implementation, which includes some heavy use of Named Formulas and the ParseJSON function (bless you, PowerFX team, these are fantastic additions!) . Essentially, I am giving users a custom UX that lets them enter data which are tracked in a Named Formula object which is then serialized to JSON and stored on a Dataverse record so that the next time a user goes to that same record and opens this custom page, we can prepopulate it with the values that were last entered... and all this without needing to add a ton of columns because we can just store it all in one clean JSON object instead.
Implementation:
This JSON object includes some object nesting... not because it particularly needs to be there, but because it makes for neater organization of the data. When I want to prepopulate a field, I have a couple named formulas for convenience like this (note: I have manually renamed all my various objects to make them more readable for this issue report, so if you see typos in any of my code snippets it is only because of that manual editing):
and when I want to use that value on the page, I have something like:
Which is in keeping with the documentation here (i.e. I don't need to explicitly cast myObject as Record before accessing booleanValue).
Issue:
But here's the problem, when I drop that value on the custom page, I get a default value, not the actual value from the JSON. That is, if the val is a bool, I get false (even if the JSON contains true). If the val is a string, I get "", no matter what that string is supposed to be, etc.
So at this point I assume I must have messed up my syntax somewhere, so like any good developer I back up a step and sanity check. I drop a simple text box on the page, just putting currentJSON on the page raw so I can make sure that I am not crazy and the bool IS supposed to be true. This is where it gets weird; the JSON (string) shows up, and confirms that I am not crazy - the bool is supposed to be true - but way more importantly, the bool value evaluated by
now shows up as true, where it was false before. OK, I must have messed up in save/publish iterations and it worked the whole time, I just was not testing cleanly, so now I just remove the currentJSON string from the page... but now the bool goes back to false!
What I think I am seeing:
What it looks like is that the combination of the Named Formulas and parseJSON (and maybe this is also just specific to custom pages) presents a bug where a named formula passed into parseJSON evaluates as Undefined until some other invocation of that named formula causes it to have a value and causes parseJSON to see its string input.
And indeed, when I kill off my intermediary formula for currentJSON and just parse the JSON in every usage:
the value on the page evaluates correctly without issue.
AND... I want to draw particular attention to that GUID function: source.id is itself also a Named Formula, yet it does not have this same problem: the GUID function is able to get a freshly evaluated copy of source.id, unlike ParseJSON.
So where is the bug?:
I'm not really sure, but if I had to guess, because both Named Formulas and ParseJSON are in their early days, I am guessing that ParseJSON is not properly evaluating the formula in its inputs and looking for a value as though it was a variable instead? I really don't know.
My hope is that this Discussion post will help to figure that out so I can register an Issue in the right place and not waste folks' time with a bug in the wrong backlog.
Beta Was this translation helpful? Give feedback.
All reactions