1

So I need to essentially create a PowerApp which would make appointments in Dynamics CRM. All data gets sent to CRM - except the case regarding the appointment.

Originally, I was using the normal SubmitForm() but switched over to the Patch() function. I have set the _regardingobjectid_value to a valid case GUID. The problem lies with _regardingobjectid_type - as for some reason, I cannot set the entity name. In this case, the entity name would be "incident", but it keeps throwing an error that states that it needs another GUID. I really don't know what to do anymore.

This is the code I am using:

Patch(
      Appointments;  
      Defaults(Appointments); 
      {
         Subject: txtSubject.Text; 
         'Start Time': DateTimeValue(_selectedStartTime); 
         'End Time': DateTimeValue(_selectedEndTime);
          Description:txtDescription.Text;
          _regardingobjectid_value: _regarding;
          _regardingobjectid_type: incident 
       }
)

So to clarify, I would just really like to have my appointment have the specified case regarded to it. At the moment I am getting an error stating that incident "name is invalid". If I remove the type, I get an ambigious error. And when I set the case id to the type, it does input my record into Dynamics, however with no case (understandably so).

John Doe
  • 11
  • 1
  • 3
  • Definitely regarding is the most complex data type, as it can point to multiple entities. can you try with some single entity lookup & patch it with existing record, maybe hard coding the values first. – Arun Vinoth-Precog Tech - MVP Apr 05 '19 at 21:41
  • When I hardcode the values, the same error appears with the _regardingobejctid_type field. It states that it needs a GUID, which I cannot seem to find a value for. I do not think entities themselves get GUID so I have no idea what to do. – John Doe Apr 07 '19 at 12:45
  • Try _regardingobjectid_value: GUID(_regarding) and _regarding should be string like “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”). Also try _regardingobjectid_type: 112 or “incident” – Arun Vinoth-Precog Tech - MVP Apr 07 '19 at 14:33
  • Hi ya'll. So, nothing seemed to work so I used a Microsoft Flow instead. And then it worked perfectly. For some reason that code just did not want to accept my values for the regarding data type. Thank you for all help and suggestions! – John Doe Apr 15 '19 at 09:34
  • did you try my below answer? – Arun Vinoth-Precog Tech - MVP Apr 15 '19 at 10:22
  • 1
    Yes sir! It still gave the same errors and problems. It's really weird as I agree that that piece of code should work. – John Doe Apr 16 '19 at 11:06
  • pls see my update, there may be a known issue today. – Arun Vinoth-Precog Tech - MVP May 24 '19 at 19:04

1 Answers1

0

This should work. Exact same problem is solved in this blog post.

You have to make sure to set this Use GUID data types instead of strings setting in App settings.

Patch(
      Appointments;  
      Defaults(Appointments); 
      {
         Subject: txtSubject.Text; 
         'Start Time': DateTimeValue(_selectedStartTime); 
         'End Time': DateTimeValue(_selectedEndTime);
          Description:txtDescription.Text;
          _regardingobjectid_value: GUID(_regarding);
          _regardingobjectid_type: “incidents” 
       }
)

Edit:

Nick mentioned in his blog about this. Should be a known bug.

The only reason why I choose Flow as opposed to writing directly to CDS from the PowerApp is that at this point you cannot set the “regarding” when you write to a task in the Canvas based PowerApp, but you can using Flow.