I have a form that I want to populate when a user clicks on a 'Copy' button. So far I have the button set up to copy the currently selected record from a gallery and store that in a global variable like this:
Set(
glbFormData,
GAL_Campaigns.Selected
);
Set(
varCopy,
true
);
EditForm(FRM_CampaignForm);
Navigate('Create Campaign')
For my form most fields I can get away with using this in the 'Default' property
Parent.Default
Or this in the 'DefaultSelectedItems' property.
[Parent.Default]
But I run into trouble with some of my other comboboxes. For example, I have a combobox that has this code in the 'DefaultSelectedItems' property.
If(
Self.DisplayMode=DisplayMode.Edit && Text(RB_Partnering.Selected.Value) = "Yes",
If(
IsBlank(newPartner),
{CB_PartnerName:Parent.Default},
newPartner
),
Blank()
)
In this case I haven't figured out a way to populate that field with the record value. Is there a way to do this?
NOTE: The last bit of code is on a combobox that is part of a two step process. If the user can not find the value they are looking for they can click an 'Add' button which hides the combobox and presents them with a text field where they can enter the missing value. Once entered they can click 'Add' and the text field and button are hidden and the original combobox comes back and is populated with the value they just entered.
Sorry for this late reply but glad you were able to sort out the issue. Ensure that you select the solution that worked for you to close off this thread.
Ok. Figured it out. It's the CB_PartnerName. That is not the name of the column. Once I changed that it worked. Simple answer which I feel like you may have answered earlier but I didn't understand.
Sure. Let me see if I can explain.
That is the basic functionality when creating a new record. That works great. What I am stuck on is copying a record.
This is where my issue is. Most fields get populated using Parent.Default or [Parent.Default]. It's just the combo boxes, that have this mechanism that allow the user to add a new record to the source data for the combo box, that fail to populate. As I mentioned in a previous post that if I remove the code that is currently there and use [Parent.Default] I see what I would expect to see. It's something about the code I am using that is preventing [Parent.Default] from being used.
It seems to me that it is the {CB_PartnerName: Parent.Default} that is the issue. If I change that entire line to [Parent.Default] (with the code being the combo box's Default property) I get an error stating "Expected Table value"
Does that help any?
Correct, what you would have to do is change the Parent.Default to ThisItem.'Partner Name'.
Apologies, I do not understand the purpose of your code so I am unable to determine if there are any changes that your code requires.
I have a question though. If that code is placed on the datacard then this code won't work because the parent of the datacard is the form is it not?
{CB_PartnerName:Parent.Default}
So the code that you have is not returning a text value. You can use the Text() function to turn the value into a text value.
Ok. Currently, the Default property uses ThisItem.'Partner Name'. If I replace that with the code from the combobox DefaultSelectedItems I get and error. 'Expected Text value'
You would have to put the code in the Default property of the datacard
Thanks. Setting the combobox's DefaultSelectedItems to [Parent.Default] certainly works to get the value I am looking for but I am stuck on the part where I am entering the code, that is currently in DefaultSelectedItems, into the datacard for that combobox. Where am I entering that? The Default for the datacard is currently ThisItem.'Partner Name'.
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional