Hi @Sumitra_Sai
Please see my answers below and INLINE
@Sumitra_Sai wrote:
Hi, I have a form like below where the user enters the person's name who are inside their organization and also have the ability to enter the names who are outside the organization. I'm using Dataverse as the backend.


- For Internal, user has the ability to select names from the people picker ComboBox. When he clicks Add Internal button, the name will get stored inside the collection.

- For External, user has the ability to give name and their corresponding email address. User clicks on Add External button, which will add those inside a collection.

And this is how, we are storing the internal and external users and displaying them inside a gallery.
Is it proper way to store both internal and external users inside a same collection?

[Michael] If I understand, your Collection looks great, but your back end is where the problem is. You should be using the same format as your Choice. Name, Email and a Choice Column (which is either Internal or External) values.
So me personally you need to change your back end to reflect what you did in your collection for it to be correct.
1. How to add serial numbers or create unique ID on creation of a record inside the gallery?
[Michael] I do not understand what you mean by created inside the gallery? How are you creating them in the Gallery?
I can understand that you maybe using a Collection that is bound to the Gallery. So are you asking, how do I generate a Unique ID that I can put in the Collection, which is being used BY the gallery?
I want to point out, that once you store it in Dataverse, it will be given a unique GUID, but that you should NOT generate this yourself and pass it to Dataverse (under 99.999999999999999% of scenarios).
But if you just want a Unique ID for whatever reason, you can add a UniqueId column and use the GUID() function to generate a GUID for it. Just remember its NOT the guid from Dataverse, its just a temporary one.
Most of the time, I don't suggest adding to a collection and then later on adding to Dataverse, many times for this reason, but I do understand sometimes it makes sense to do so.
2. Now, how to patch all of them inside the dataverse column on click of Submit button?

[Michael] I have a sample Table called TestList. I have bound it to a Gallery. Now I am going to pretend like I want to add new records for each row in the gallery.
What this does is loops through all the Gallery7.AllItems, and does a Patch on my Table, using the syntax Defaults(TestList), which mean new row, and then I supply the data for my columns
But the other thing you see is that I have an If statement. That is because how you have your backend, I have to figure out do I populate the internal or the external columns.
My if statement is completely wrong. I don't know if the gallery has a PersonType or how the heck you will know to populate the Internal versus External columns, but thats where you would.
ForAll(Gallery7.AllItems,
If(ThisRecord.PersonType = "Internal",
Patch(TestList, Defaults(TestList),
{
InternalPeopleName: ThisRecord.Name,
InternalPeopleEmail: ThisRecord.Email,
Id: IdLabel.Text // I made up this name
}
);
,
Patch(TestList, Defaults(TestList),
{
ExternalPeopleName: ThisRecord.Name,
ExternalPeopleEmail: ThisRecord.Email,
Id: IdLabel.Text // I made up this name
}
);
)
);
3. And also how to get corresponding Internal Mail ID for the respective user as we are fetching only Display names from the combobox? (Using Office365 Users) and need to patch along with them.

Or is there any other way to achieve this?
[Michael]
This is a little... bit of guess work on my part. But here is how I would do it.
If your gallery gets the PersonType from your Collection, then the solution is pretty easy
(and by mail id, you just mean the primary Email address right?)
Step 1. Add a textlabel to your gallery.
Step 2. In the Text property, AND assuming your gallery is using your PersonType column from the colletion (again however you spell it im guessing). Then you would do this in the Text property
Here it checks to see if my phoney PersonType = Internal
If it does, I put two things here so you can pick which one you want (Id or Mail)
If it does NOT equal Internal, then it just puts ""
If the ThisItem.PersonType is blank it just puts ""
If(!IsBlank(ThisItem.PersonType),
If(ThisItem.PersonType = "Internal",
// Here you will do the Office365User Query to get their Mail id.
Office365Users.SearchUser({searchTerm:ThisRecord.InternalPersonName})).Mail
//or you can do
Office365Users.SearchUser({searchTerm:ThisRecord.InternalPersonName})).Id
,
""
),
""
)
Please see ABOVE where I used this value to update the User Table. Again a guess.
I would really appreciate if this helps if you can Mark it as an Answer/Resolved and maybe even a thumbs up.
Cheers
If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey