ReferenceError: ConferenceDataService is not defined

Deadly 提交于 2020-05-15 22:52:49

问题


I am trying to develop google calendar add-on like zoom meeting.

In appsscript.json file, below code is there.

 "calendar": {
      "conferenceSolution": [{
        "onCreateFunction": "createConference",
        "id": "1",
        "name": "Meeting",
        "logoUrl": "https://companyxyz.com/images/logo192.png"
      }],
      "eventOpenTrigger": {
        "runFunction": "buildSimpleCard"
      },
      "currentEventAccess": "READ_WRITE"      
    }
  }

In Calendar.gs, below code is there.

function createConference(e) {
  Logger.log(e);
  var dataBuilder = ConferenceDataService.newConferenceDataBuilder();
  return dataBuilder.build();  
}
/**
   * Build a simple card with a button that sends a notification.
   * This function is called as part of the eventOpenTrigger that builds
   * a UI when the user opens a Calendar event.
   *
   * @param e The event object passed to eventOpenTrigger function.
   * @return {Card}
   */
  function buildSimpleCard() {
    var buttonAction = CardService.newAction()
        .setFunctionName('onSaveConferenceOptionsButtonClicked')
        .setParameters(
          {'phone': "1555123467", 'adminEmail': "joyce@example.com"});
    var button = CardService.newTextButton()
        .setText('Add new attendee')
        .setOnClickAction(buttonAction);
    var buttonSet = CardService.newButtonSet()
      .addButton(button);

    var section = CardService.newCardSection()
               .setHeader("addon")
            .addWidget(buttonSet);

   var card = CardService.newCardBuilder()
      .addSection(section)
      //.setFixedFooter(footer);

   return card.build();
    // Check the event object to determine if the user can set
    // conference data and disable the button if not.
  //  if (!e.calendar.capabilities.canSetConferenceData) {
     // button.setDisabled(true);
 //   }

    // ...continue creating card sections and widgets, then create a Card
    // object to add them to. Return the built Card object.
  }

  /**
   * Callback function for a button action. Sets conference data for the
   * Calendar event being edited.
   *
   * @param {Object} e The action event object.
   * @return {CalendarEventActionResponse}
   */
  function onSaveConferenceOptionsButtonClicked(e) {
    var parameters = e.commonEventObject.parameters;

    // Create an entry point and a conference parameter.
    var phoneEntryPoint = ConferenceDataService.newEntryPoint()
      .setEntryPointType(ConferenceDataService.EntryPointType.PHONE)
      .setUri('tel:' + parameters['phone']);

    var adminEmailParameter = ConferenceDataService.newConferenceParameter()
        .setKey('adminEmail')
        .setValue(parameters['adminEmail']);

    // Create a conference data object to set to this Calendar event.
    var conferenceData = ConferenceDataService.newConferenceDataBuilder()
        .addEntryPoint(phoneEntryPoint)
        .addConferenceParameter(adminEmailParameter)
        .setConferenceSolutionId(1)
        .build();

    return CardService.newCalendarEventActionResponseBuilder()
        .setConferenceData(conferenceData)
        .build();
  }

I have published this add-on from Publish->Deploy from menifest.

Executing this code giving me error of ReferenceError: ConferenceDataService is not defined.

I have searched all the possible references, but not able to get any solution. Please suggest me proper solution for this.


回答1:


According to this comment from this issue here, it looks like there has been a change regarding this.

When testing the above code, the ReferenceError: ConferenceDataService is not defined. is not displayed anymore and the code runs as expected.

For other methods specific to the ConferenceDataService you can check the documentation here.

Reference

  • Apps Script ConferenceDataService.
  • Cannot create conference with 3rd party Conference Solution from conference solutions Dropdown in Google Calendar


来源:https://stackoverflow.com/questions/60928984/referenceerror-conferencedataservice-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!