Get Event List

Scenario

Get a list of the next week's events on a user's calendar from Microsoft Graph using GET REST functions and show the events in a calendar jig.

Resource links:

Required OAuth scope (least to most privilege):

Calendars.Read Calendars.ReadWrite

Related Sample

This example uses Get Calendar List to provide the calendar input to the view-calendar-events jig and navigates to Get Event Item when the event item is pressed.

List events
List events

Examples and code snippets

General

index.jigx
name: ms-graph-demonstrator
title: MS Graph Demonstrator
description: A sample solution that uses the Microsoft Graph API. You can deploy and use this solution without any additional configuration.
category: business
home:
    jigId: calendar-summary
    icon: home-apps-logo
    jigId: next-meeting
    when: |
      [email protected]=null? false:true
    icon: meeting-remote

onFocus:
  type: action.action-list
  options:
    isSequential: true
    actions:
      - type: action.sync-entities
        options:
          provider: DATA_PROVIDER_REST
          entities:
            - entity: next-week-calendar-events
              function: get-calendar-events-next-week
              parameters:
                accessToken: microsoft.OAuth
                startdatetime: =$fromMillis($millis())
                enddatetime: =$fromMillis($millis()+604800000)
            - entity: calendars
              function: get-calendar-list
              parameters:
                accessToken: microsoft.OAuth

Functions

MS Graph Event List function in GitHub.

provider: DATA_PROVIDER_REST
method: GET
url: https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events
outputTransform: $
useLocalCall: true
parameters:
  accessToken:
    location: header
    required: true
    type: string
    value: microsoft.OAuth #Use manage.jigx.com to define credentials for your solution
  calendarId:
    type: string
    location: path
    required: true
  $top:
    type: string
    location: query
    required: false
    value: 100
  $filter:
    type: string
    location: query
    required: false
records: =$.value
continuation:
  when: =$."@odata.nextLink"
  url: =$."@odata.nextLink"
  parameters:
    accessToken:
      location: header
      required: true
      type: string
      value: microsoft.OAuth

Jigs

MS Graph Calendar Events List jig in GitHub.

view-calendar-events.jigx
title: Calendar
type: jig.calendar

header:
  type: component.jig-header
  options:
    height: small
    children:
      type: component.image
      options:
        source:
          uri: https://support.content.office.net/en-us/media/f1c4b693-4670-4e7a-8102-bbf1749e83fe.jpg

# sync the events for the selected calendar by calendarId
onFocus:
  type: action.sync-entities
  options:
    provider: DATA_PROVIDER_REST
    entities:
      - entity: calendarEvents
        function: get-calendar-event-list
        parameters:
          accessToken: microsoft.OAuth
          calendarId: [email protected]
          $filter: ="start/dateTime ge '" & $fromMillis($millis()-86400000) & "' and end/dateTime le '" & $fromMillis($millis()+5184000000) & "'"

onRefresh:
  type: action.sync-entities
  options:
    provider: DATA_PROVIDER_REST
    entities:
      - entity: calendarEvents
        function: get-calendar-event-list
        parameters:
          accessToken: microsoft.OAuth
          calendarId: [email protected]
          $filter: ="start/dateTime ge '" & $fromMillis($millis()-86400000) & "' and end/dateTime le '" & $fromMillis($millis()+5184000000) & "'"

datasources:
  calendarEvents:
    type: datasource.sqlite
    options:
      provider: DATA_PROVIDER_LOCAL
      entities:
        - entity: calendarEvents
      jsonProperties:
        - attendees
      query: |
        SELECT id,
        '$.id' as eventId,
        '$.createdDateTime',
        '$.lastModifiedDateTime',
        '$.originalStartTimeZone',
        '$.originalEndTimeZone',
        '$.reminderMinutesBeforeStart',
        '$.isReminderOn',
        '$.hasAttachments',
        '$.subject',
        '$.bodyPreview',
        '$.importance',
        '$.sensitivity',
        '$.isCancelled',
        '$.isOrganizer',
        '$.showAs',
        '$.webLink',
        json_extract(Data, '$.onlineMeetingUrl.joinUrl') as onlineMeetingUrl,
        '$.isOnlineMeeting',
        '$.onlineMeetingProvider',
        '$.onlineMeeting',
        json_extract(Data, '$.body.contentType') as bodyContentType,
        json_extract(Data, '$.body.content') as bodyContent,
        json_extract(Data, '$.start.dateTime') || 'Z' as startTime,
        json_extract(Data, '$.end.dateTime') || 'Z' as endTime,
        '$.location',
        '$.attendees',
        '$.organizer'
        FROM [calendarEvents]

data: [email protected]
item:
  type: component.event
  options:
    from: [email protected]
    to: [email protected]
    title: [email protected]
    location: "='Importance: ' & @ctx.current.item.importance"
    description: [email protected]
    people: "[email protected].{'fullName': emailAddress.address, 'email': emailAddress.address}"
    buttonTitle: View Event Details
    onPress:
      type: action.go-to
      options:
        linkTo: view-calendar-event-details-w
        parameters:
          eventId: [email protected]
          evtFrom: [email protected]
          evtTo: [email protected]
          bodyContent: [email protected]
          summary: [email protected]
          subject: [email protected]
          onlineMeetingUrl: [email protected]
          isOnlineMeeting: [email protected]
          bodyPreview: [email protected]
          attendees: [email protected]
          onlineMeetingProvider: [email protected]

actions:
  - children:
      - type: action.go-to
        options:
          title: Create New Event
          linkTo: create-calendar-event

See Also

Last updated

Was this helpful?