cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EricD
Frequent Visitor

Dependent Lookup issues

Thank you for any help: This is my first post and first Power App so please be gentle...

I have a Power App that is connected to a SharePoint list, RequestForm. I have a field where an Agent's ID is typed in. I am looking for to use  AgentID to look up the agent's name and other information from a different SharePoint list, EmpInfo. I am looking to display the retrieved name in the Power App and also save  to the list RequestForm. the PopwerApp is run directly off of the SharePoint list through SharePoint Integration and is not using collections.

 

I have tried multiple approaches:

1:  setting a default value for AgentName field: it would pull the Name in preview mode but not when published (it would stay blank and would not update SharePoint).

2: Setting an OnChange on the AgentID field: UpdateContext({'AgentName': LookUp(EmpInfo, ID='AgentID' , EmpName)}) or 'AgentName'=LookUp(EmpInfo, ID='AgentName', Empname)

 

Any help is appreciated.

 

An additional, related task: I want to take the AgentID and populate additional columns in RequestForm without displaying them in Power App (like the agent's supervisors email)

22 REPLIES 22

Thank you for all of your help.

 

I'm looking for any method that would allow me to save the looked up value for the agent's name and have it save on the same row as the rest of the data when its submitted.

---------------------------------

putting

LookUp(
   EmpInfo, 
   ID='AgentID'.Text, 
   EmpName
)

 as the default value for the AgentName  field doe not write anything when the form is submitted

------------------------------

this writes to the form, but on the wrong row:

SubmitForm(SharePointForm1);
With(
   {
      vAgent:
      LookUp(
         EmpInfo, 
         ID='AgentID'.Text, 
         EmpName
      )
   },
   If(
      !IsBlank(vAgent),
      UpdateIf(
         YourSharePointListName,
         'AgentName'=SharePointIntegration.Selected.'AgentName',
         {'AgentName': vAgent}
      )
   );
   Refresh(YourSharePointListName)
)

 

thank you,


Eric

Thanks @EricD ,

This does not make a lot of sense to me as the same Lookup either in the Default of the field or in a Variable for a Patch has got to produce the same result, however try this (not ideal however)

SubmitForm(SharePointForm1);
Refresh(YourSharePointListName);
With(
   {
      vAgent:
      LookUp(
         EmpInfo, 
         ID='AgentID'.Text, 
         EmpName
      )
   },
   If(
      !IsBlank(vAgent),
      UpdateIf(
         YourSharePointListName,
         'AgentName'=SharePointForm1.LastSubmit.'AgentName',
         {'AgentName': vAgent}
      )
   );
   Refresh(YourSharePointListName)
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

I took your idea and ran with it. I set the name as a global variable, and then added your code to OnSave. it seams to be working so far. will go back and clean it up a little later..

 

omg, who know something so simple as saving a value could be such a nightmare...

 

thank you again so much

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,747)