I have a situation where I need to set a part of a global variable(record) to blank if a certain action is taken. I've tried the following but it's a no-go. Is there a way to do this?
Set(glbFormData.'First Value', Blank());
UpdateContext({glbFormData.'First Value': Blank()});
Description of the controls
The idea behind the newFirst variable is it gives me the ability to set the DSI of FirstValue_CB to newFirst if a value is present otherwise use the value of Parent.Default. I was getting stuck when there is a value in FirstValue_CB and the Source_CB was set to a value that didn't contain "1st" in the selected value. FirstValue_CB would still get submitted.
Does that help explain things in a little more detail?
Try to cut back on variables and setting variables in OnChange actions. These will trip you up over and over. Simply have your formulas reference conditions that you have in your app.
So, let's say that newFirst (I have no idea what you have for that) is a dropdown in your form called dropdown1.
Instead of trying to set a variable on the OnChange, you would just change the formula you have to the following:
{crfeb_firstvalue:
If(Self.DisplayMode=DisplayMode.Edit,
Coalesce(Dropdown1.Selected.Value, Parent.Default),
Blank()
)
}
FirstValue is a field. I revisited another set of fields I was working on and I think this variation might do the trick.
If(Self.DisplayMode=DisplayMode.Edit, If(IsBlank(newFirst),{crfeb_firstvalue:Parent.Default},newFirst), Blank())
Note that newFirst is a variable being set by another field when that field's value is submitted.
Chances are...
Usually when you start introducing in OnChange actions, things are going the wrong way.
You are trying (in the OnChange) to set a FirstValue to blank. I would ask this - is the FirstValue a field of your form? If so, then you should be looking at it from the perspective of the control in the form getting the value it needs based on the condition rather than trying to slip the change in underneath to the form record.
Hmm. Maybe I am overcomplicating things. This seems like a lot of work for little functionality.
If you're changing the record variable that is the Item of the editform, it should update the values on the form itself. However, keep in mind that once a control is changed (i.e. a dropdown, etc) it will retain its value.
So, instead of resetting the form, consider resetting the controls that appear to be losing their values.
Hmmm. ResetForm works to get those values back but it also resets the field I changed that triggers the ResetForm thereby resetting it's value as well.
When I change the combobox that has this formula in the OnChange property it sets that combobox and every other combobox to show no values. At least visually.
If(!("1st" in Source_CB.Selected.crfeb_source), Set(glbFormData, Patch(glbFormData, {crfeb_firstvalue: Blank()})))
If I add a label and set the text to the datacard default value like this then there is data showing since it is pulling from the glbFormVariable. (First Value DC is obviously blank now if I try to access its default)
Source_DC.Default
Yes, giving the wrong name will certainly do that. Nothing more frustrating than even misspelling a column and then the designer re-evaluates all the schema before you can correct it. Once that happens...the designer is "lost". You've got to exit and start again. I with there was a "re-evaluate schemas" option in the designer.
As for the other issue you are seeing - can you describe that a little more?
@RandyHayes
I see what happened. I used the wrong column name. Should have been crfeb_firstvalue. Error is gone now, however, doing something like this sets all of the fields, that use a DSI, to blank even though the data still exists in the glbFormData variable
If(!("1st" in Source_CB.Selected.crfeb_source), Set(glbFormData, Patch(glbFormData, {crfeb_firstvalue: Blank()})))
The typical DSI looks like
{crfeb_source:Parent.Default}
Is this because the glbFormData variable needs to be reevaluated somehow?
WarrenBelz
146,605
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,946
Most Valuable Professional