web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I get my field ...
Power Apps
Answered

How do I get my field to populate with Parent.Default and keep some custom coding?

(0) ShareShare
ReportReport
Posted on by 831 Moderator

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.

Categories:
I have the same question (0)
  • rpersad Profile Picture
    776 on at

    The problem could be due to the items property of the combo box does not have the option for the default value selected.

     

    Also is there a reason why you are only showing a value when the combo box display mode is "Edit"

  • futr_vision Profile Picture
    831 Moderator on at

    Right. I've been trying to figure out how to add that [Parent.Default] back into this code. Nothing I've tried works. 

     

    As for the 'Edit' mode condition. I'm not exactly sure why I added that. Typically, there is a reason. I need to explore that more.

  • rpersad Profile Picture
    776 on at

    When building a form the fields in the form are in a card, which is the parent, and the card has a DataField property which links it to the column of the data source. 

     

    Is the combo box that you are having trouble with in an edit form which is linked to a data source? If so, can you check the card's DataField property to and see if it has the data source column name.

  • futr_vision Profile Picture
    831 Moderator on at

    Checked and it does have a Datafield property with the column name.

  • rpersad Profile Picture
    776 on at

    Assuming that you checked and ensured that your if functions were giving the correct results for the scenario what you can do is enter the same code into the default property of the DataCard, which the combo box is in, and set the DefaultSelectedItems property of the combo box to 'Parent.Default'.

     

    Of course if you have code which sets the DisplayMode of the combo box you can either set the DisplayMode of the Data Card as well or change the code to reference the display mode of the combo box.

    You would have to change, 'Self.DisplayMode' to 'comboboxname.DisplayMode' in the code.

  • futr_vision Profile Picture
    831 Moderator on at

    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'. 

  • rpersad Profile Picture
    776 on at

    You would have to put the code in the Default property of the datacard

  • futr_vision Profile Picture
    831 Moderator on at

    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'

  • rpersad Profile Picture
    776 on at

    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.

  • futr_vision Profile Picture
    831 Moderator on at

    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}

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard