1

CRM 公开操作,它允许您通过 Web API 执行它们。

例如,以下是WinOpportunity操作模式和 API:

<Action Name="WinOpportunity">
  <Parameter Name="OpportunityClose" Type="mscrm.opportunityclose" Nullable="false" />
  <Parameter Name="Status" Type="Edm.Int32" Nullable="false" />
</Action>

要执行此问题,您将发布以下内容:

POST [Organization URI]/api/data/v8.2/WinOpportunity HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

{
 "Status": 3,
 "OpportunityClose": {
  "subject": "Won Opportunity",
  "opportunityid@odata.bind": "[Organization URI]/api/data/v8.2/opportunities(b3828ac8-917a-e511-80d2-00155d2a68d2)"
 }
}

有没有办法执行 BookRequest 操作?

在检查 CSDL 模式时,我发现此操作定义为:

<Action Name="Book">
<Parameter Name="Target" Type="mscrm.crmbaseentity" Nullable="false"/>
<Parameter Name="ReturnNotifications" Type="Edm.Boolean"/>
<ReturnType Type="mscrm.BookResponse" Nullable="false"/>
</Action>

此 Book 操作的请求将是什么样的?

4

1 回答 1

1

参考MSDNBookRequest消息预计AppointmentTarget. 预订行动也是如此。

// Create the ActivityParty instance.
ActivityParty party = new ActivityParty
{
    PartyId = new EntityReference(SystemUser.EntityLogicalName, userResponse.UserId)
};

// Create the appointment instance.
Appointment appointment = new Appointment
{
    Subject = "Test Appointment",
    Description = "Test Appointment created using the BookRequest Message.",
    ScheduledStart = DateTime.Now.AddHours(1),
    ScheduledEnd = DateTime.Now.AddHours(2),
    Location = "Office",
    RequiredAttendees = new ActivityParty[] { party },
    Organizer = new ActivityParty[] { party }                        
};                    

// Use the Book request message.
BookRequest book = new BookRequest
{
    Target = appointment
};

参考MSDN,webapi 请求可能如下所示:(正在使用现有的约会记录,仍然收到 400 Bad request)

POST [Organization URI]/api/data/v8.2/Book HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

{
 "Target": {
  "activityid": "59ae8258-4878-e511-80d4-00155d2a68d1",
  "@odata.type": "Microsoft.Dynamics.CRM.appointment"
 }
}
于 2018-02-20T04:48:41.013 回答