Hello everyone,
I'm trying to create an appointment in an appointment via JavaScript.
The user should insert data in three fields startDateFollowApp, endDateFollowApp and subjectFollowApp.
I've searched through many posts & Blogs, but couldn't find an answer, which worked.
After time I've created a JavaScriptCode, from the link below, but it didn't work either.
function create_appointment(id){
//myID
var myId = frames[1].Xrm.Page.data.entity.getId();
//Create the activityparty
activityparty myParty = new activityparty();
myParty.partyid = CrmTypes.CreateLookup(EntityName.systemuser.ToString(), myId);
//Create the appointment Object
appointment myAppointment = new appointment();
//Set the appointment Object's properties
myAppointment.description = "description";
myAppointment.ownerid = CrmTypes.CreateOwner(EntityName.systemuser.ToString(), myId);
myAppointment.scheduledstart = DateTime.Now.AddHours(1);
myAppointment.scheduledend = DateTime.Now.AddHours(2);
myAppointment.location = "location";
myAppointment.subject = "subject";
myAppointment.regardingobjectid = id;
//Create the Target
TargetScheduleAppointment myAppointmentTarget = new TargetScheduleAppointment();
//Set the Target's Properties
myAppointmentTarget.Appointment = myAppointment;
//Create the Request Object
BookRequest myBookRequest = new BookRequest();
//Set the Request Object's Properties
myBookRequest.Target = myAppointmentTarget;
//Execute the Request
BookResponse booked = (BookResponse) myService.Execute(myBookRequest);
}
The id, I get with
lookup = Xrm.Page.getAttribute("regardingobjectid").getValue();
if (lookup != null) {
var name = lookup[0].name;
var id = lookup[0].id;
var entityType = lookup[0].entityType;
}
Here my question, is somebody out there, who has solved the Problem or knew why my code isn't working.
Regards,
CRM_Believer