In this post, I’m focusing on how to create a record based on the User entity in CDS.
In some scenarios, we may have to create records from power apps based on current logged in user’s names. In this blog, I’m creating a record based on the current logged in users name.
My CDS has an entity named “HR Teams”. It has fields called “HR Name” and “DOB”. I should have taken much better names, but I realized it after creating it.
So basically, When I click on the “Create” button in the below image, a record will be created in “HR Team” entity with “HR Name” as the current logged in users name and “DOB” as whatever you enter in the textbox.
I have added the below code on the “On select” property of the button.
Patch(‘HR Teams’,Defaults(‘HR Teams’),{‘HR Name’:LookUp(Users,’Full Name’=User().FullName),DOB:TextInput1.Text})