cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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
Highlighted
Community Support
Community Support

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
Highlighted
Super User III
Super User III

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.
Highlighted
Community Support
Community Support

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

Highlighted
Anonymous
Not applicable

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,

 

@Anonymous 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (4,155)