Tuesday, January 29, 2019

Web Services > C# .NET > Creating a calendar event via web services into NetSuite.

The following code will tell you how to create a calendar event in netsuite, it will also tell you how to add attendees to the event and set the start and end times for the event. 
   
    // NetSuite Calendar Event Object
    CalendarEvent ce = new CalendarEvent();

    // Calendar Event Title
    ce.title = "Test Event 1";

    // Calendar Status of the Organizer
    ce.status = CalendarEventStatus._confirmed;

    // Event is set to public so everyone who uses the account can see it in the activites
    ce.accessLevel = CalendarEventAccessLevel._public;

    // Creation date set to today using Native C# methods
    ce.createdDate = System.DateTime.Today;

    // StartDate is really the start time and it starts from 00 or 12:00 am
    ce.startDate = System.DateTime.Today.AddHours(10);
    ce.startDateSpecified = true;

    // EndDate is really the end time and it starts from 00 or 12:00 am
    ce.endByDate = System.DateTime.Today.AddHours(11);
    ce.endByDateSpecified = true;

    //Setting the organizer as the administrator of the account.
    RecordRef ceo = new RecordRef();
    ceo.internalId = "-5";
    ce.organizer = ceo;

    //Creating the invited attendees to the event.
    CalendarEventAttendeeList calEvtAtdLst = new CalendarEventAttendeeList();
    CalendarEventAttendee[] calAtdLst = new CalendarEventAttendee[2];
    CalendarEventAttendee calAtd = new CalendarEventAttendee();
    CalendarEventAttendee calAtd1 = new CalendarEventAttendee();
    CalendarEventAttendee calAtd2 = new CalendarEventAttendee();

    // The internal id is the internal id of an employee in the company
    RecordRef atd1 = new RecordRef();
    atd1.internalId = "12";
    calAtd.attendee = atd1;
    calAtdLst[0] = calAtd;

    // The internal id is the internal id of an employee in the company
    RecordRef atd2 = new RecordRef();
    atd2.internalId = "126";
    calAtd1.attendee = atd2;
    calAtdLst[1] = calAtd1;

    // The internal id is the internal id of an employee in the company
    RecordRef atd3 = new RecordRef();
    atd3.internalId = "-5";
    calAtd2.attendee = atd3;
    calAtdLst[1] = calAtd2;

    // Assigns the attendee list to the calendar event attendee's
    calEvtAtdLst.attendee = calAtdLst;
    ce.attendeeList = calEvtAtdLst;

    // Processes the creation of the calendar event and sends it to netsuite
    Status res1 = nss.add(ce).status;

    // if the calendar event has been added successfully it will display this message in the console.
    if (res1.isSuccess)
    {
        Console.Write("Login Success, Event Created.");
        Console.Read();
    } 

    // if the calendar event has not been added successfully it will display this message in the console.
    else
    {
        Console.Write("Login Success, Event not Created");
        Console.Read();
    }

1 comment:

  1. The next occasion I read a weblog, I am hoping that this doesnt disappoint me just as much as this. I mean, Yes, it was my substitute for read, but I just thought youd have something fascinating to talk about. All I hear can be a bunch of whining about something that you could fix when you werent too busy searching for attention. Live Streaming / Web streaming

    ReplyDelete