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

Issues collecting other column values from related Dataverse table

Hi all

 

I have run into a problem showing collecting values from other columns from a related Dataverse table.

 

I have two tables that are related:

  • Projects
    • Name
    • Contact (Lookup Column for Contacts Table)
    • ContactID
    • Start
    • Finish
  • ContactsXero
    • Name
    • ContactID (This is a Contact ID from another application)

 

Here is an image of the relationships

Screen Shot 2022-05-22 at 4.14.31 pm.png

 

I have a collection called ‘colProjects’ that is modelled off the Projects table.

 

I have a form that has a Combobox control and sources it’s values from the ‘ContactsXero’ table.

 

I can successfully select a Contact, update the colProjects collection with the Contact and patch Dataverse.

 

Where I am having issues is updating the colProjects collection with the ContactID from ContactsXero. This should be simple enough.

 

Here is a sample of my update code:

 

UpdateIf(colProjects,

    cr07e_projectsid = cr07e_projectsid,

        {

            //Project Core Fields

            cr07e_name: cbContact.Selected.cr07e_name,

            cr07e_contact: cbContact.Selected,           

            cr07e_contactid: cbContact.Selected.cr07e_contactid

            }

)

 

The result of:

‘cr07e_contactid: cbContact.Selected.cr07e_contactid’

is Blank.

 

I can workaround by performing a lookup on the name column, however this would be error prone if there happens to be two contacts with the same name, but more to the point, I shouldn’t have to perform a more complicated lookup.

Am I missing something here?

 

Any help would be greatly appreciated.

2 REPLIES 2
timl
Super User
Super User

@Nebulas 

Most likely, this is due to 'Explicit Column Selection'.

I guess the Items property of your cbContact combobox control is set to ‘ContactsXero'.

If you change this to explicitly sepecify cr07e_contactid and the other fields that you want to display with ShowColumns, it should hopefully not return blank when you call cbContact.Selected.cr07e_contactid.

ShowColumns(ContactsXero,
         cr07e_contactid,
         OtherColumnsYouWantToShow
)
Nebulas
Helper I
Helper I

Thanks for your reply @timl 

 

I get some very mixed results when I try your selection. Basically one step forward, and two steps back.

 

If I use ShowColumns and include the columns of interest in the ComboBox Items field, the part of the code that updates the LookUp field (See below) breaks. Assuming this is because the Contact selected from the Combobox is now a different dimension to what it is expecting.

 

cr07e_contact: cbContact.Selected,

 

So if I comment out the update to the LookUp column (cr07e_contact:), then cr07e_contactid successfully updates the collection with the correct contactID from the Combobox. But as soon as I re-enable updating the LookUp column the code breaks. I even tried a workaround by using LookUp the Contact from ContactsXero table on the condition of the cr07e_contactid value and the result is the same; Back to successfully updating the LooKup column cr07e_contact, but the r07e_contactid is Blank again.

 

On no level does this make any sense to me.

 

Just some more info:

 

When I use your suggested

ShowColumns(ContactsXero, "cr07e_contactsid", "cr07e_name", "cr07e_contactid")

It shows the correct data - See below.

Screen Shot 2022-05-23 at 8.35.46 am.png

 

When I use my original 

SortByColumns(ContactsXero,"cr07e_name", Ascending)

It also shows the correct data - See below.

Screen Shot 2022-05-23 at 9.10.55 am.png

 

So to me it appears that the only thing using ShowColumns is doing, is narrowing the amount of fields used in the ComboBox items.

 

Another very odd this that I will look into more, it that if I then edit a newly created record, it does successfully update both the Contact Lookup and the ContactID.

 

Welcome any other suggestions.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,219)