Google Calendar Schedule Append

Adds the appointment specified by String type data item to the time period specified by DateTime type data item on Google Calendar, and stores its communication log in a String type data item

    A. Set OAuth2 Config Name (at [OAuth 2.0 Setting])Single-line inputRequired
    B. Select STRING/SELECT for Calendar ID (Non-existent Error)Data selectString(single line)orSelect(radio/select/search)Required
    C. Select STRING DATA for Event TitleData selectString(single line)Required
    D. Select DATETIME DATA for Event StartData selectDatetimeRequired
    E. Select DATETIME DATA for Event End (Not-selected +1:00)Data selectDatetime
    F. Select STRING DATA for LocationData selectString(single line)
    G. Select STRING DATA for DescriptionData selectString
    H. Set Default Time Zone ("America/New_York" "GMT+9:00")Single-line inputRequired
    I. Select STRING/SELECT DATA for Start TZData selectString(single line)orSelect(radio/select/search)
    J. Select STRING/SELECT DATA for End TZData selectString(single line)orSelect(radio/select/search)
    K. Set EventSource Title (e.g. "BPMS" "#{processInstanceTitle}")Single-line inputInserting EL expressions is also possible
    L. Set EventSource URL (e.g. "${var[applicationRoot]}")Single-line inputInserting EL expressions is also possible
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_OAuth2Set OAuth2 Config Name (at [OAuth 2.0 Setting])
    Bconf_DataIdBSelect STRING/SELECT for Calendar ID (Non-existent Error)
    Cconf_DataIdCSelect STRING DATA for Event Title
    Dconf_DataIdDSelect DATETIME DATA for Event Start
    Econf_DataIdESelect DATETIME DATA for Event End (Not-selected +1:00)
    Fconf_DataIdFSelect STRING DATA for Location
    Gconf_DataIdGSelect STRING DATA for Description
    Hconf_EventTimeZoneSet Default Time Zone ("America/New_York" "GMT+9:00")
    Iconf_DataIdISelect STRING/SELECT DATA for Start TZ
    Jconf_DataIdJSelect STRING/SELECT DATA for End TZ
    Kconf_EventSourceSet EventSource Title (e.g. "BPMS" "#{processInstanceTitle}")
    Lconf_EventSourceUrlSet EventSource URL (e.g. "${var[applicationRoot]}")
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // Insert Event to Google Calendar via Calendar API v3 (ver. 20161025)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    //// == 工程コンフィグの参照 / Config Retrieving ==
    var oauth2 = configs.get( "conf_OAuth2" );
    var dataIdB = configs.get( "conf_DataIdB" ); // (returns Number)
    var dataIdC = configs.get( "conf_DataIdC" ); // (returns Number)
    var dataIdD = configs.get( "conf_DataIdD" ); // (returns Number)
    var dataIdE = configs.get( "conf_DataIdE" ); // (returns Number)
    var dataIdF = configs.get( "conf_DataIdF" ); // (returns Number)
    var dataIdG = configs.get( "conf_DataIdG" ); // (returns Number)
    var eventStartTimeZone = configs.get( "conf_EventTimeZone" ) + ""; //default
    var eventEndTimeZone = configs.get( "conf_EventTimeZone" ) + ""; //default
    var dataIdI = configs.get( "conf_DataIdI" ); // (returns Number)
    var dataIdJ = configs.get( "conf_DataIdJ" ); // (returns Number)
    var eventSource = configs.get( "conf_EventSource" ) + "";
    var eventSourceUrl = configs.get( "conf_EventSourceUrl" ) + "";
    var dataIdX = configs.get( "conf_DataIdX" ); // (returns Number)
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var calendarId = "";
    if( data.get( dataIdB ) instanceof java.util.ArrayList ){
      calendarId = data.get( dataIdB ).get(0).getValue() + "";
    }else if( data.get( dataIdB ) instanceof java.lang.String ){
      calendarId = data.get( dataIdB ) + "";
    }
    var eventSummary = data.get( dataIdC ) + "";
    var eventStart = data.get( dataIdD ).toString() + "";
    eventStart = eventStart.replace(" ", "T") + ":00";
    if( dataIdE !== "" && data.get( dataIdE ) !== null ){
      var eventEnd = data.get( dataIdE ).toString() + "";
      eventEnd = eventEnd.replace(" ", "T") + ":00";
    }else{
      var eventEnd = data.get( dataIdD ).addHours(1).toString() + "";
      eventEnd = eventEnd.replace(" ", "T") + ":00";
    }
    var eventLocation = "";
    if( dataIdF !== "" && data.get( dataIdF ) !== null ){
      eventLocation = data.get( dataIdF ) + "";
    }
    var eventDescription = "";
    if( dataIdG !== "" && data.get( dataIdG ) !== null ){
      eventDescription = data.get( dataIdG ) + "";
    }
    if( dataIdI !== "" ){
      if( data.get( dataIdI ) instanceof java.util.ArrayList ){
        eventStartTimeZone = data.get( dataIdI ).get(0).getValue() + "";
        eventEndTimeZone = data.get( dataIdI ).get(0).getValue() + "";
      }else if( data.get( dataIdI ) instanceof java.lang.String ){
        eventStartTimeZone = data.get( dataIdI ) + "";
        eventEndTimeZone = data.get( dataIdI ) + "";
      }
    }
    if( dataIdJ !== "" ){
      if( data.get( dataIdJ ) instanceof java.util.ArrayList ){
        eventEndTimeZone = data.get( dataIdJ ).get(0).getValue() + "";
      }else if( data.get( dataIdJ ) instanceof java.lang.String ){
        eventEndTimeZone = data.get( dataIdJ ) + "";
      }
    }
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var token = httpClient.getOAuth2Token( oauth2 );
    
    var uri = "https://www.googleapis.com/calendar/v3/calendars/";
    uri += calendarId;
    uri += "/events";
    
    var myObj = {};
    myObj.summary = eventSummary;
    myObj.location = eventLocation;
    myObj.description = eventDescription;
    myObj.start = {};
    myObj.start.dateTime = eventStart;
    myObj.start.timeZone = eventStartTimeZone;
    myObj.end = {};
    myObj.end.dateTime = eventEnd;
    myObj.end.timeZone = eventEndTimeZone;
    myObj.source = {};
    if( eventSource !== "" ){
      myObj.source.title = eventSource;
    }
    if( eventSourceUrl !== "" ){
      myObj.source.url = eventSourceUrl;
    }
    //debug
    //accessLog += JSON.stringify( myObj ) + "\n"; 
    
    var response = httpClient.begin()
      .bearer( token )
      .body( JSON.stringify( myObj ), "application/json" )
      .post( uri );
    accessLog += "---POST request--- " + response.getStatusCode() + "\n";
    accessLog += response.getResponseAsString() + "\n";
    
    //// == ワークフローデータへの代入 / Data Updating ==
    if( dataIdX !== "" ){
      retVal.put( dataIdX, accessLog );
    }
    

    • B’: Google Calendar ID ** stored in the Data Item selected at config B
    • C’: Schedule Title stored in the Data Item selected at config C
    • D’: Scheduled start time stored in the Data Item selected at config D
    • E’: Scheduled end time stored in the Data Item selected at config E
    • F’: Location information stored in the Data Item selected at config F
    • G’: Details of the schedule stored in the Data Item selected at config G
    • I’: TimeZone of start time stored in the Data Item selected at config I
    • J’: TimeZone of end time stored in the Data Item selected at config J
    • Schedule C’ which starts at D’ and ends at E’ is added to the Google Calendar B’
    • The communication logs are stored in the data item selected in config X
    • *Refer to the following page for Calendar ID
      • [Calendar Settings] > [Calendar Address]
    • You need to register Project at Google API Manager beforehand (Scope: “https://www.googleapis.com/auth/calendar”)
    • Schedule (event) with a start time and end time will be added (You cannot add an “all-day schedule”)
    • When the end time data item has not been set or the end time has not been input, 60 minutes after start time will be set
    • Schedule which the end time is earlier than the start time will not be added to the calendar
    • If data item of TimeZone for the start and end time has not been set or has not been input, default TimeZone (the value of the config H) will be set
    • Follow IANA Database Name for the format of TimeZone setting (e.g. “GMT+9:00” “America/New_York”)
    • To embed a direct link to the details of an Issue in Questetra on the calendar, set the value of “# {processInstanceTitle}” into the config K, the value of “${var[applicationRoot]}OR/ProcessInstance/listView?processInstanceId=#{processInstanceId}” into the config L