cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
msm8504
Level: Powered On

Set 2nd lookup field based on value of a variable

Hello,

Using the CDS connector connecting to D365, I'm attempting to auto set a 2nd lookup field based on value of a variable within my 1st lookup field.  Has anyone had success with this?  I'm basically defining a variable and attempting to perform an IF statement with my drop down lookup field, for example: If(myVar=1, [DDLValue]="Yes").

 

Also, I am using combobox controls for my lookup fields since I am using the CDS connector.  Does this provide any limitations on what I'm trying to accomplish?

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Set 2nd lookup field based on value of a variable

Hi @msm8504 ,

Could you please share a bit more about your scenario?

Do you want to auto set the 2nd LookUp field value within your 1st LookUp field (ComboBox)?

 

Based on the issue that you mentioned, I think there is something wrong with your Operation. Currently, within PowerApps, we could not assign or set a value to a property of another control within one control.

Currently, you could consider set default value for the 2nd LookUp filed directly based on a variable within your Edit form.

 

I have made a test on my side, please take a try with the following workaround (the TaskLists field on my side represents the 2nd LookUp field in your scenario😞8.JPG

Set the Items property of the ComboBox within the TaskLists (LookUp field) data card to following:

Choices([@Tasks].crba2_TaskLists_Task)

On your side, you should set the Items property of the ComboBox within your 2nd LookUp Data card to following:

Choices('YourEntity'.YourSecondLookUpField)

 

Set the DefaultSelectedItems property of the ComboBox within the TaskLists (LookUp field) data card to following:

If(
myVar=1,
LookUp(Choices([@Tasks].crba2_TaskLists_Task),'Primary Name' = "Task2"),
Parent.Default
)

On your side, you should set the DefaultSelectedItems property of the ComboBox within your 2nd LookUp data card to following:

If(
    myVar=1, 
    LookUp(Choices('YourEntity'.YourSecondLookUpField), 'Primary Name' = "A specific Value"), /* <-- Find the specific record from your Referenced Entity based on a specific value */
    Parent.Default
)

Note: The Referenced Entity represents the Entity your 2nd LookUp filed reference values from.

 

Please take a try with the above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Set 2nd lookup field based on value of a variable

@msm8504 

You need to consider looking at it from the opposite direction.  Controls consume (are bound) to properties rather than setting them directly.

So, in the case of your DropDown, you'll want to look at the Default value. 

Something like  If(myVar=1, "Yes") in the Default property of the DropDown would give you what you want.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: Set 2nd lookup field based on value of a variable

Hi @msm8504 ,

Could you please share a bit more about your scenario?

Do you want to auto set the 2nd LookUp field value within your 1st LookUp field (ComboBox)?

 

Based on the issue that you mentioned, I think there is something wrong with your Operation. Currently, within PowerApps, we could not assign or set a value to a property of another control within one control.

Currently, you could consider set default value for the 2nd LookUp filed directly based on a variable within your Edit form.

 

I have made a test on my side, please take a try with the following workaround (the TaskLists field on my side represents the 2nd LookUp field in your scenario😞8.JPG

Set the Items property of the ComboBox within the TaskLists (LookUp field) data card to following:

Choices([@Tasks].crba2_TaskLists_Task)

On your side, you should set the Items property of the ComboBox within your 2nd LookUp Data card to following:

Choices('YourEntity'.YourSecondLookUpField)

 

Set the DefaultSelectedItems property of the ComboBox within the TaskLists (LookUp field) data card to following:

If(
myVar=1,
LookUp(Choices([@Tasks].crba2_TaskLists_Task),'Primary Name' = "Task2"),
Parent.Default
)

On your side, you should set the DefaultSelectedItems property of the ComboBox within your 2nd LookUp data card to following:

If(
    myVar=1, 
    LookUp(Choices('YourEntity'.YourSecondLookUpField), 'Primary Name' = "A specific Value"), /* <-- Find the specific record from your Referenced Entity based on a specific value */
    Parent.Default
)

Note: The Referenced Entity represents the Entity your 2nd LookUp filed reference values from.

 

Please take a try with the above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

TopShelf-MSFT
Level 10

Re: Set 2nd lookup field based on value of a variable

Thanks for posting in the community @msm8504 - can you review the above replies and update the thread if they were helpful? 

 

Thank you,

 

@TopShelf-MSFT 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,450)