{
var soapCtx = ServiceHelper.GetSingletonSoapService();
var activityId = Guid.NewGuid();
var appt = new Entity()
{
Id = activityId,
LogicalName = "appointment"
};
appt["activityid"] = activityId;
appt["scheduledstart"] = DateTime.Now.Date;
appt["scheduledend"] = DateTime.Now.Date.AddHours(1);
appt["description"] = "Test 1 2 3";
appt["subject"] = "Test Command Button Appointment";
appt["location"] = "Location 1 2 3";
soapCtx.BeginCreate(appt, ar =>
{
var response = soapCtx.EndCreate(ar);
var bookRequest = new OrganizationRequest();
bookRequest.RequestName = "Book";
bookRequest["Target"] = appt;
soapCtx.BeginExecute(bookRequest,
new AsyncCallback(OnBookRequestedCompleted), soapCtx);
}, null);
});
void OnBookRequestedCompleted(IAsyncResult ar)
{
var soapCtx = (IOrganizationService)ar.AsyncState;
var response = soapCtx.EndExecute(ar);
}
No comments:
Post a Comment