While Removing conenctor in MSTeams, "registerOnRemoveHandler" method is called twice.

%3CLINGO-SUB%20id%3D%22lingo-sub-1583447%22%20slang%3D%22en-US%22%3EWhile%20Removing%20conenctor%20in%20MSTeams%2C%20%22registerOnRemoveHandler%22%20method%20is%20called%20twice.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1583447%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20remove%20a%20connector%20from%20MSTeams%2C%20i%20have%26nbsp%3B%20noticed%20that%26nbsp%3B%20%22registerOnRemoveHandler%22%20method%20is%26nbsp%3B%20executing%20twice%2C%20and%20in%20this%26nbsp%3B%20method%26nbsp%3B%20i%20have%26nbsp%3B%20written%20AJAX%20calls%20for%26nbsp%3B%20removing%26nbsp%3B%20dependencies%20of%26nbsp%3B%20connector%2C%20but%20as%20method%20is%20called%20twice%2C%20AJAX%26nbsp%3B%20call%20also%20called%20twice.%3C%2FP%3E%3CP%3Ei%20am%20not%20able%20to%20find%20why%20this%20is%26nbsp%3B%20happening%20in%20this%20method.%3C%2FP%3E%3CP%3ECan%20someone%20help%20me%20with%20it%3F%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1583447%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586905%22%20slang%3D%22en-US%22%3ERe%3A%20While%20Removing%20conenctor%20in%20MSTeams%2C%20%22registerOnRemoveHandler%22%20method%20is%20called%20twice.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586905%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F745982%22%20target%3D%22_blank%22%3E%40sunnykalola%3C%2FA%3E%26nbsp%3B-Could%20you%20please%20check%20did%20you%20write%20two%20instance%20for%20the%20method%3F%20Also%20could%20you%20please%20conform%20are%20you%20implemented%20the%20method%20as%20documented%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2Fmicrosoft-teams-sample-connector-csharp%2Fblob%2Fmaster%2FTeamsToDoAppConnector%2FViews%2FConnector%2FSetup.cshtml%23L65%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20%3FIf%20no%20could%20you%20please%20share%20repro%20steps%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1588852%22%20slang%3D%22en-US%22%3ERe%3A%20While%20Removing%20conenctor%20in%20MSTeams%2C%20%22registerOnRemoveHandler%22%20method%20is%20called%20twice.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1588852%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20You%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F590590%22%20target%3D%22_blank%22%3E%40Nikitha-MSFT%3C%2FA%3E%26nbsp%3B.%20I%20haven't%20write%26nbsp%3B%202%20instance%20for%20the%20method.%20Also%20i%20have%20referred%20a%20link%20which%20you%20had%26nbsp%3B%20shared%20there%20is%26nbsp%3B%20%26nbsp%3Bone%20variable%26nbsp%3B%20%22%3CSPAN%3E%3CSTRONG%3EremoveCalled%3C%2FSTRONG%3E%3C%2FSPAN%3E%22%20which%26nbsp%3B%20value%20is%26nbsp%3B%20set%20as%20true%20and%26nbsp%3B%20below%26nbsp%3B%20that%20i%20have%26nbsp%3B%20implement%20my%20AJAX%20call.but%26nbsp%3B%20then%20also%20it's%20called%20twice.%3CBR%20%2F%3Ebelow%20is%20a%20sample%20code%20%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3EmicrosoftTeams.settings.registerOnRemoveHandler(function%20(removeEvent)%20%7B%0A%20%20var%20removeCalled%20%3D%20true%3B%20%20%0A%20%20%2F%2F%20AJAX%20Call%0A%20%20%24.ajax(%7B%0A%20%20%20%20url%3A%20%22https%3A%2F%2Fexample.com%22%2C%0A%20%20%20%20type%3A%20%22DELETE%22%2C%0A%20%20%20%20data%3A%20%22string%22%2C%0A%20%20%20%20contentType%3A%20%22application%2Fjson%22%2C%0A%20%20%20%20success%3A%20function%20()%20%7B%0A%20%20%20%20%20%20removeEvent.notifySuccess()%3B%0A%20%20%20%20%7D%2C%0A%20%20%20%20error%3A%20function%20()%20%7B%0A%20%20%20%20%20%20removeEvent.notifyFailure(%22Failed%22)%3B%0A%20%20%20%20%7D%0A%20%20%7D)%3B%0A%7D)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1598548%22%20slang%3D%22en-US%22%3ERe%3A%20While%20Removing%20conenctor%20in%20MSTeams%2C%20%22registerOnRemoveHandler%22%20method%20is%20called%20twice.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1598548%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F745982%22%20target%3D%22_blank%22%3E%40sunnykalola%3C%2FA%3E%26nbsp%3B-%20Could%20you%20please%20try%20the%20code%20mentioned%20in%20sample%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I am trying to remove a connector from MSTeams, i have  noticed that  "registerOnRemoveHandler" method is  executing twice, and in this  method  i have  written AJAX calls for  removing  dependencies of  connector, but as method is called twice, AJAX  call also called twice.

i am not able to find why this is  happening in this method.

Can someone help me with it??

3 Replies
Highlighted

@sunnykalola -Could you please check did you write two instance for the method? Also could you please conform are you implemented the method as documented here ?If no could you please share repro steps?

Highlighted

Thank You @Nikitha-MSFT . I haven't write  2 instance for the method. Also i have referred a link which you had  shared there is   one variable  "removeCalled" which  value is  set as true and  below  that i have  implement my AJAX call.but  then also it's called twice.
below is a sample code :

microsoftTeams.settings.registerOnRemoveHandler(function (removeEvent) {
  var removeCalled = true;  
  // AJAX Call
  $.ajax({
    url: "https://example.com",
    type: "DELETE",
    data: "string",
    contentType: "application/json",
    success: function () {
      removeEvent.notifySuccess();
    },
    error: function () {
      removeEvent.notifyFailure("Failed");
    }
  });
})
Highlighted

@sunnykalola - Could you please try the code mentioned in sample?