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

Create Appointment using SDK.REST but getting error like "Undefined"

$
0
0

I am facing issue in create appointment using SDK.REST and I have already referenced   SDK.REST.js  for using SDK.REST but still getting error like undefined.

below is my code :

function createAppointment(accountId,accountName) {
                alert(accountId);
                    var appointment = {};
                    if (confirm("Are you sure want to complete this Appointment?") == true) {
                        appointment.Name = "Appointment";
                        appointment.Description = "This account was created by the JavaScriptRESTDataOperations sample.";
                        
                        appointment.Subject = "Appointment "+accountName;
                        var today = new Date();
                        var startDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 3);
                        appointment.ScheduledStart = startDate;
                        appointment.ScheduledEnd = startDate;

                        if (accountId != null) {
                            //Set a lookup value
                            //writeMessage("Setting the primary contact to: " + primaryContact.FullName + ".");
                            appointment.new_RegardingCustomer = {
                                Id: accountId,
                                LogicalName: "account",
                                Name: accountName
                            };
                            
                            
                            var organizerParty = new Object();
                            organizerParty.partyid = { Id: accountId , LogicalName: "account", Name: accountName };

                            appointment.RequiredAttendees = [ organizerParty ];
                            //appointment.requiredattendees = [ organizerParty ];
                            
                        }

                        
                        //Create the Account
                        SDK.REST.createRecord(
                            appointment,
                            "Appointment",
                            function (appointment) {
                            alert("The appointment record changes were saved");
                                // writeMessage("The account named \"" + account.Name + "\" was created with the AccountId : \"" + account.AccountId + "\".");
                                // writeMessage("Retrieving account with the AccountId: \"" + account.AccountId + "\".");
                                // retrieveAccount(account.AccountId)
                            },
                            errorHandler
                        );
                    } else {
                        return false;
                    }
                    <!-- this.setAttribute("disabled", "disabled"); -->
                }

please check and letus know if have any query in code so I can move forward.

Thank you.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



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