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

ComboBox with FirstName and Lastname linked to Employee Table ID

I am trying to create a standard ComboBox to show all employee names from an employee table which has employee_fname and employee_sname as separte fields.

I need the ComboBox to show FullNames of Employees and save result to main table which has foreign key EmployeeID using the employee_ID primary key taken from the employees table.

At the moment I have managed to show FullName on search and only First Name not FullName in ComboBox View after selected.

Therefore when you navigate to Edit Form it only shows First Name. To View full name you need to select drop down.

Both Tables are stored in SQL Gateway.

Note the app is refrencing 2 tables [dbo].[tblVanJourneyLog] this has foreign key EmployeeID, Also [dbo].[tblEmployee] which has primary key employee_ID. See attached for configuration.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

There are two things you should consider changing in your formula:

 

NamesList:  Change this to your own datasource:  '[dbo].[Employee]'

EmployeeID:  If the column name in your datasource has a different name changed this as well.

 

Before changes (your code from the previous post):

 

ShowColumns(
    Filter(
        AddColumns(
            NamesList,
            "FullName",
            Concatenate(employee_fname," ",employee_sname)
        ),
        Value(DataCardValue1.Text) = EmployeeID
    ),
    "FullName"
)

 

After changes:

 

ShowColumns(
    Filter(
        AddColumns(
            '[dbo].[Employee]',
            "FullName",
            Concatenate(employee_fname," ",employee_sname)
        ),
        Value(DataCardValue1.Text) = your_employee_id_column_name
    ),
    "FullName"
)

 

I tested this on my side so it should work once you've got all of the functions setup properly.  I think we're getting close to solved!

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

10 REPLIES 10
Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

You could use the Concatenate() function to show both FirstName and LastName in the selected ComboBox item.  In general, I think the following forum post does an excellent job of explaining what to do.  If you try what the post suggests but cannot figure it out let me know.

 

Concatenate() Forum Post Link

https://powerusers.microsoft.com/t5/Creating-Apps/Combo-Box-with-Multiple-columns/td-p/71363

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

AndyRossco
Level: Powered On

Re: ComboBox with FirstName and Lastname linked to Employee Table ID


@mdevaney wrote:

@AndyRossco 

You could use the Concatenate() function to show both FirstName and LastName in the selected ComboBox item.  In general, I think the following forum post does an excellent job of explaining what to do.  If you try what the post suggests but cannot figure it out let me know.

 

Concatenate() Forum Post Link

https://powerusers.microsoft.com/t5/Creating-Apps/Combo-Box-with-Multiple-columns/td-p/71363

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."



Hi  mdevaney,

                          This does not resolve what I am trying to do, the link shows how to get around using office365 contacts I think.

I am very new to Powerapps and all I want to do is simulate an access combobox which shows employee_fname & " " & employee_sname as FullName

and then stores employee_ID in Main table which has foriegn field to Employee table. Please see document attached.

Also if I do use Concatenate() where do i put code for this in datacard items or combobox se

Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

I put together a brief example for you to show how a ComboBox can display a combined first name and last name.

 

In your table, the column Full Name does not exist so we'll have to create it just for the combo box.  Go to the Items property of the combo box and write the following code.  Note how I used a Concatenate function to join the First Name and Last Name separated by a space.

 

AddColumns(your_datasource_name, "FullName", Concatenate(FirstName," ",LastName))

Change the DisplayFields property of the combo box to the name of your new column.  Make sure to put the column name in between double quotes.

 

["FullName"]

 

Then set the SearchFields property of the combo box to the code below.  This allows the user to search either First Name or Last Name.  Make sure the column names are in between double quotes.

 

["FirstName","LastName"]

 

Finally, change the layout to Single as shown below.

 

img1.png

 

Let me know if this helped!

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

 

 

AndyRossco
Level: Powered On

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

Thanks mdevaney, this has worked on initial selection, it shows FullName now.

But when you go back to Edit screen from detail screen it does not show actual person that was selected, it just shows "Select Name" which is set in the InputTextPlaceHolder property.

 

Maybe something to do with Default or DefaultSelectedItems ?

 

The Default property on the combobox at the moment is empty.

The DefaultSelectedItems I have set to 

LookUp('[dbo].[Employee]',employee_id = EmployeeID)

Annotation 2019-09-25 102204.jpgAnnotation 2019-09-25 102240.jpg

 

 

 

Thanks for your patience I appreciate your help.

Andy

Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

Nice to hear the combo box is working for you.  Now let's focus on getting that Edit screen working.

 

I'm having some trouble visualizing the problem.  Would you be willing to post 2 pictures: one showing the Edit Screen and another showing the Detail Screen?  Then I can see exactly what you are seeing and it will be easier to problem solve.

 

Also, can you please clarify what order the user progresses through the screens?  Is it:

a) starts on the detail screen then goes to the edit screen?

b) starts on the edit screen then goes to the detail screen?

 

AndyRossco
Level: Powered On

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

mdevaney,

                 Thanks for reply, please see attached view of detail form and edit form. I am trying to show Employee Name where it shows EmployeeID

As you can see forms are only in basic development at moment. I am waiting to put to bed the Combox issue I have.

The ComboBox selection is working and storing the EmployeeID in the Main Table at the moment, now I need to show FullName in detail form and

Edit Form as record stored is EmployeeID I need to pull FullName from Employees table.

I have used standard Form Flow as per created automatically from SQL Data, So I have a browse screen, Detail Screen and Edit Screen.

The Browse screen needs alot of sorting yet to show data which is linked to 2 other tables, I need to develope this different. That will be my next task.

Thanks in advance, Andy

 

 

Annotation 2019-09-25 150628.jpgEdit Screen

Annotation 2019-09-25 151754.jpgBrowse ScreenAnnotation 2019-09-25 151207.jpgDetail Screen

 

Annotation 2019-09-25 151754.jpg 

Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

DefaultSelectedItems expects a single column Table as an argument.  You used LOOKUP which returns a single value field.  You'll want to use FILTER instead and combine it SHOWCOLUMNS as shown below. 

 

Put this code in DefaultSelectedItems and replace any table names/fields with your own.  Value(lbl_employeeID.Text) should reference the label name of the employee number on the Detail screen.  I converted this to a number using VALUE, but you may not have to depending on whether employeeID is a Text or a Number within your tables.

 

ShowColumns(
    Filter(
        AddColumns(
            NamesList,"FullName",Concatenate(
                FirstName," ",LastName
                )
            ),
    Value(lbl_employeeID.Text) = employeeID),
"FullName")

Try it out.  Let me know if it works.

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

AndyRossco
Level: Powered On

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

Dear mdevaney, Thanks again, but

                            No Luck with this, I tried see picture, not sure what I am doing wrong.

ShowColumns(Filter(AddColumns(NamesList,"FullName",Concatenate(employee_fname," ",employee_sname)),Value(DataCardValue1.Text) = EmployeeID),"FullName")

 

 

Annotation 2019-09-25 171636.jpg

 

Here is picture of Detail Screen

 

Annotation 2019-09-25 172058.jpgDetail Screen

Super User
Super User

Re: ComboBox with FirstName and Lastname linked to Employee Table ID

@AndyRossco 

There are two things you should consider changing in your formula:

 

NamesList:  Change this to your own datasource:  '[dbo].[Employee]'

EmployeeID:  If the column name in your datasource has a different name changed this as well.

 

Before changes (your code from the previous post):

 

ShowColumns(
    Filter(
        AddColumns(
            NamesList,
            "FullName",
            Concatenate(employee_fname," ",employee_sname)
        ),
        Value(DataCardValue1.Text) = EmployeeID
    ),
    "FullName"
)

 

After changes:

 

ShowColumns(
    Filter(
        AddColumns(
            '[dbo].[Employee]',
            "FullName",
            Concatenate(employee_fname," ",employee_sname)
        ),
        Value(DataCardValue1.Text) = your_employee_id_column_name
    ),
    "FullName"
)

 

I tested this on my side so it should work once you've got all of the functions setup properly.  I think we're getting close to solved!

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
thirdimage

Coming Soon: T-Shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

thirdimage

Power Apps 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

Top Solution Authors
Top Kudoed Authors
Users online (6,146)