Insert Text in Editor window - Opens a Blank Modal

Hi All,

I am building a custom app for ticket_conversation_editor placeholder.
The app is using interface method to insert text in editor window in already open editor. However a blank modal windows opens up whenever I click on app icon to insert the text in editor. Verified my code and there is no where I am opening or calling interface method to open any modal.

Any idea what could be the reason.

Oh.

@Sachin_Kumar - Is it possible you can share the zip file of the app that I can use to reproduce the issue? I am guess there can be possible difference in how you interface method is used.

Hi @Saif

Thanks for your response. It a sample custom app to put entire conversation history in reply editor. Please find below app code.

document.onreadystatechange = function () {
  if (document.readyState === 'interactive') renderApp();

  function renderApp() {
    var onInit = app.initialized();
    onInit
      .then(function getClient(_client) {
        window.client = _client;
        client.events.on('app.activated', renderReplyInEditor);
      })
      .catch(handleErr);
  }
};

function renderReplyInEditor() {

  client.data.get("ticket").then((ticketDetail) => {
    client.data.get("domainName").then((domainDetail) => {
      let ticket_conversations = getConversations(domainDetail.domainName, ticketDetail.ticket.id, 1, []);
      Promise.all([ticket_conversations]).then(function (data) {
        let conversations = data[0];
        console.log(conversations);

        let user_conversations = conversations.filter(converstation => (converstation.private === false));
        let conIdx = user_conversations.length - 1;
        if (user_conversations.length > 3) {
          client.interface.trigger("click", { id: "deleteQuotedText" })
            .then(function () {

              conIdx = user_conversations.length - 1;
              body_text = ``;
              for (let i = conIdx; i > 0; i--) {
                body_text += user_conversations[i].body;
              }
              client.interface.trigger("setValue", { id: "editor", text: body_text, replace: true });
            }).catch(handleErr);
        }
              
      }).catch(handleErr);
    }, error => {
      handleErr(error)
    });
  }, error => {
    handleErr(error)
  });
}

function getConversations(domainName, ticketId, page, conversations) {
  const dataUrl = `https://${domainName}/api/v2/tickets/${ticketId}/conversations`;
  const options = { headers: { "Authorization": "Basic <%= encode(iparam.apiKey) %>" } };
  return new Promise(function (resolve, reject) {
    client.request.get(dataUrl, options).then(function (data) {
      let response = JSON.parse(data.response);
      conversations = conversations.concat(response);
      page++;
      if (response.length != 0) {
        getConversations(page, conversations).then(function (data) {
          resolve(data);
        }, function () {
          resolve(conversations);
        });
      } else {
        resolve(conversations);
      }
    }).catch(function (err) {
      reject(err);
    });
  });
}

function handleErr(err = 'None') {
  console.error(`Error occured. Details:`, err);
}

And the manifest.json

{
  "platform-version": "2.2",
  "product": {
    "freshdesk": {
      "location": {
        "ticket_conversation_editor": {
          "url": "index.html",
          "icon": "styles/images/icon.svg"
        }
      }
    }
  },
  "whitelisted-domains": ["https://*.freshdesk.com"],
  "engines": {
    "node": "14.17.3",
    "fdk": "8.3.3"
  }
}

@Sachin_Kumar,
Good Day!
As per your code, there is nothing related to opening the modal, might be an issue with the product :thinking:

Can you please share the App.zip to investigate further?

We will report it to the product team if it is a bug.

Thanks

1 Like

Hi @Santhosh

Thanks for your response. PFA .zip
AddConversationsTrail_Debug.zip (7.3 KB)

@Sachin_Kumar,
Seems like this is an issue with the product,
Let me reach out to the product team and get it solved.

Thanks for reporting!

1 Like

@Santhosh

Thanks a lot.

Seems like the Freshdesk team has recognized this is a problem, and the issue has been logged.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.