
I'll try and explain this the best that I can. These 3 fields all work together. The Third Party field is hidden unless you choose a value that contains "3rd" in it.
If("3rd" in Source_CB.Selected.crfeb_source,true,false)
The Add Third Party field(group) is hidden if the add3rdPtyGRP variable is false. The Add Third Party button OnSelect sets this variable to true which reveals the group. It also sets add3rdPtyBTN to false which sets its Visible property to false.
When you type a value into the Add Third Party field and click Add a variable called newThird is set to the value of the Add Third Party field. This value is then patched to the datasource of the Third Party field and the field is refreshed like this
Note: add3rdPtyGRP and add3rdPtyBTN are also changed although this is not important
If(
!IsBlank(AddThirdParty_TB.Value),
UpdateContext(
{
newThird: Patch(
'Third Parties',
{'Third Party (crfeb_thirdparty)': AddThirdParty_TB.Value}
)
}
);
Reset(AddThirdParty_TB)
);
Set(
add3rdPtyGRP,
false
);
Set(
add3rdPtyBTN,
true
)
All fine and dandy. The DefaultSelectedItems property for Third Party is set to newThird if a value exists otherwise it defaults to the parent like this.
If(IsBlank(newThird),{crfeb_thirdparty:Parent.Default},newThird)
Again, all is great, however if I am editing or making a copy of the original record and change the value in the Source field to a value that does not contain "3rd" in the value the default value of the parent still exists behind the scenes in a global variable called glbFormData. What I basically need to be able to do, in the case of an edit/copy where the Source changes to a value that does not contain "3rd" is make that Third Party field blank in glbFormData so that when I submit it that value is no longer available. I'm not sure exactly how to do this though. I need to be able to account for the existence of a value in the newThird variable and use that value in the Third Party field when the conditions match otherwise I need to use the value in glbFormData for Third Party unless the Source field does not contain "3rd" in the value in which case I then need to set the glbFormData.'Third Party' to blank.
Hopefully that is clear. It's barely clear to me and my non-programmer mind. Lol!