Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Create Appointment in Appointment

$
0
0

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.

https://social.microsoft.com/Forums/en-US/4c1dc56d-2d3d-423e-875f-2512592e8d18/creating-appointment-dynamically-from-plugin?forum=crmdevelopment

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


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>