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

Error while creating new record in dynamic 365 entity using patch function

Hello all powerapps users,

 

I have two custom entity in Dynamic 365,

    First entity name:  Bookable Resource

    Second entity name : Alternate Resource

 

Bookable Resource entity has a column called, "Name" column type is Single Line Text.

Alternate Resource entity has a column called, "Team" column type is Lookup (Lookup of Name Column).

 

I want to create a new record in AlternateResource entity, however record created properly but my value not inserted in Team column. (Team is lookup type column of Name).

 

.

Team.jpg

 

Below patch functioin creates new record in entity:

 

Patch(
AlternateResource,
Defaults(AlternateResource),
{
'Task Type': Value(DataCardValue1.Text),
'Task Head': Value(DataCardValue5.Text),
}
);

 

But when i use lookup column (Team) in patch, that gives me error.

 

Patch(
AlternateResource,
Defaults(AlternateResource),
{
'Task Type': Value(DataCardValue1.Text),
'Task Head': Value(DataCardValue5.Text),

'Team':Textinput1.text
}
);

 

I dont know how to play with lookup column,

so please Help me, how can i create a new record properly in my Entity.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Error while creating new record in dynamic 365 entity using patch function

Hi @sachinsoni441,

Could you please share a bit more about the error message with your Patch formula? Does it say that the 'new_myemployee' column not exist within your Demo2 data source?

Based on the formula that you mentioned, I think there is something wrong with it. Please take a try to modify your formula as below:

Patch(
         Demo2,
         Defaults(Demo2),
         {
              _new_myemployee_value: ComboBox1.Selected.new_employee   /* <-- Type _new_myemployee_value rather than 'new_myemployee' */
         }
)

You could find the corresponding LookUp column name via using property select operator (.) after the Demo2 data source. Please take a try with the following formula within your app:

Demo2.

then all available columns/properties would be shown up after it, you could find the LookUp column name/property.

Please check the attached GIF screenshot for more details:

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 REPLIES 4
Community Support Team
Community Support Team

Re: Error while creating new record in dynamic 365 entity using patch function

Hi @sachinsoni441,

Does the Team column (Team Member) column a LookUp column in your Alternate Resource entity?

Could you please share more details about the error message with your Patch formula?

Based on the formula that you provided, I think there is something wrong with it.

Actually, within Dynamics 365, the LookUp column search the corresponding value via a unique Parimary GUID string (e.g. '') of the target Entity. On your side, the Team column in your Alternate Resource search the corresponding value via a unique Primary GUID string in your Bookable Resource Entity.

I have made a test on my side, please take a try with the following workaround:11.JPG

 

12.JPG

Firstly, please turn off/disable the "Use column display name" option and "Use GUID data type instead of strings" option within Advanced settings of Apps settings of your app.

Set the Items property of the Combo Box control within the Team Data card (LookUp column) to following:

Choices([@'Alternate Resource'].new_Team)

 

Set the OnSelect property of the "Patch" button to following formula:

Patch(
'Alternate Resource',
Defaults('Alternate Resource'),
{
new_name: DataCardValue15.Text,
_new_team_value: DataCardValue18.Selected.new_bookableresourceid /* <-- DataCardValue18 represents the Combo Box control within the Team Data card */
}
)

On your side, you should type:

Patch(
        AlternateResource,
        Defaults(AlternateResource),
        {
          prefix_task_type: Value(DataCardValue1.Text),
          prefix_task_head: Value(DataCardValue5.Text),
          prefix_team_value: TeamComboBox.Selected.prefix_bookableresourceid  /* <-- The TeamComboBox represents the Combo Box within the Team Data card in your Edit form */
        }
)

 

The user @Digit89  and @Kipetcoff have faced similar issue with you, please check my response within the following thread:

https://powerusers.microsoft.com/t5/General-Discussion/Set-CRM-Dynamics-Lookup-data-type-error/m-p/1...

https://powerusers.microsoft.com/t5/Creating-Apps/Dynamics-365-Look-up-field-update/td-p/198429

 

 

Best regards,

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sachinsoni441
Level: Powered On

Re: Error while creating new record in dynamic 365 entity using patch function

Hello @v-xida-msft,

 

Actually I am very confused with Lookup Approch. so for testing purpose i create two new entity 

 

First Entity Name: Demo1

Second Entity Name: Demo2

 

Demo1 has a column name Employee type of Single line of Text

Demo2 has a column name MyEmployee which is type of Lookup column of Employee Field (Demo1)

 

Demo1 Entity:Demo1.jpg

 

 

Demo2 Entity:

 

 

I already turn off the "Use column display name" option and "Use GUID data type instead of strings".

Testing.jpg

 

 

 

 

So i want to create new record in Demo2 Entity, to store My Employee (from Emoployee Column of Demo1 Entity). for this i create one edit form on screen, and add one combo box control in edit form, Please check ComboBox Item Property (I am not sure it is right or not),  after that i creates one button, which is use to perform patch functionality.

 

 

 

ComboBox Functionality:

Testing2.jpg

 

 

Patch Functionality:

 

Testing.jpg

 

Testing.jpg

 

 

 

 

Error: The function 'Patch' has some invalid Arguments.

Due to this small dilemma, I have spoiled my whole day, please help to resolve this issue.

 

Highlighted
Community Support Team
Community Support Team

Re: Error while creating new record in dynamic 365 entity using patch function

Hi @sachinsoni441,

Could you please share a bit more about the error message with your Patch formula? Does it say that the 'new_myemployee' column not exist within your Demo2 data source?

Based on the formula that you mentioned, I think there is something wrong with it. Please take a try to modify your formula as below:

Patch(
         Demo2,
         Defaults(Demo2),
         {
              _new_myemployee_value: ComboBox1.Selected.new_employee   /* <-- Type _new_myemployee_value rather than 'new_myemployee' */
         }
)

You could find the corresponding LookUp column name via using property select operator (.) after the Demo2 data source. Please take a try with the following formula within your app:

Demo2.

then all available columns/properties would be shown up after it, you could find the LookUp column name/property.

Please check the attached GIF screenshot for more details:

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sachinsoni441
Level: Powered On

Re: Error while creating new record in dynamic 365 entity using patch function

Hello @v-xida-msft ,

 

Working perfectly, Thanks

 

Can I set default user in Combo Box Control, Which may be came from another Drop down.

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 220 members 4,757 guests
Please welcome our newest community members: