Coder Social home page Coder Social logo

Comments (6)

mmanjaree-msft avatar mmanjaree-msft commented on August 10, 2024

@RaveendraReshma Can you share the code snippet of your handler function. We are unable to repro this issue at our end.

from office-js.

RaveendraReshma avatar RaveendraReshma commented on August 10, 2024

@mmanjaree-msft

Below is the event in the launchevents.js file. Where we are fetching the recipients and storing it.

let runningMRCH = false;
const onMessageRecipientsChangedHandler = async(event) => {
    let taskpaneOpen = localStorage.getItem("TaskpaneOpen");
    if (!runningMRCH && (taskpaneOpen == null || taskpaneOpen == "N")) {
        runningMRCH = true;
        const itemId = await getItemId();
        let recipientsTo;
		let recipientsCc;
		let recipientsBcc
        try {
                if (event.changedRecipientFields.to) {
                    recipientsTo = await fetchRecipient(
                        Office.context.mailbox.item.to
                    );                  
                } else if (event.changedRecipientFields.cc) {
                    recipientsCc = await fetchRecipient(Office.context.mailbox.item.cc);                   
                }
                else {
                    recipientsBcc = await fetchRecipient(
                        Office.context.mailbox.item.bcc
                    );
                }
				let allRecipients = [
                    ...recipientsTo,
                    ...recipientsCc,
                    ...recipientsBcc,
                ];
				updateCombineRecipientArray(itemId, allRecipients);

            
        } catch (error) {
            store.dispatch(
                setErrorMessage(
                    `err`
                )
            );
        }
        runningMRCH = false;
    } else {        
    }
};

Below is the event in react component to keep track of recipients when user enters recipients while taskpane is open.

useEffect(() => {
    Office.onReady(async () => {
      let itmID = await getItemId();
      localStorage.setItem("currentItemId", JSON.stringify(itmID));
      await setItemId1(itmID);
      const itemType = Office.context.mailbox.item.itemType;

      if (itemType === Office.MailboxEnums.ItemType.Message) {
        Office.context.mailbox.item.addHandlerAsync(
          Office.EventType.RecipientsChanged,
          onMessageRecipientsChangedHandler1
        );
      } 
  }, []);
  
let runningMRCH1 = false;
  async function onMessageRecipientsChangedHandler1(event) {
    localStorage.setItem("TaskpaneOpen", "Y");
    if (!runningMRCH1) {
      runningMRCH1 = true;
      const itemType = Office.context.mailbox.item.itemType;
      if (itemType === Office.MailboxEnums.ItemType.Message) {
        const itemId = await getItemId();
        let combineList = getRecipientsForItemId(itemId);
        if (event.changedRecipientFields.to) {
          let recipientsTo = await fetchRecipient(
            Office.context.mailbox.item.to
          );         
        }
        else if (event.changedRecipientFields.cc) {
          let recipientsCc = await fetchRecipient(Office.context.mailbox.item.cc);         
        }
        else {
          let recipientsBcc = await fetchRecipient(
            Office.context.mailbox.item.bcc
          );         
        }
      } else {
      }
      runningMRCH1 = false;
    }
    localStorage.setItem("TaskpaneOpen", "N");
  }

So basically we are storing the recipients fetched in launchevents.js file and painting the recipient data onto taskpane and along with this we are also real time update feature where when user enters recipients while taskpane is open then, we are appending the recipients and updating the recipient data in the taskpane.

from office-js.

RaveendraReshma avatar RaveendraReshma commented on August 10, 2024

@mmanjaree-msft

Here when user adds any recipients while taskpane is open, the event from react component should trigger and complete its execution so the recipient list gets updated so the taskpane will have the updated data.

from office-js.

rkpathak avatar rkpathak commented on August 10, 2024

@RaveendraReshma What do you mean by "event gets triggered but never completes"?
The platform is responsible for calling Addin event handler code and its calling the enevnt handler as you mentioned.
Add-in launch-event handlers are expected to be short-running, lightweight, and as noninvasive as possible. Its addin event handler that is responsible for calling event.completed method.
You can find more details here. https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/autolaunch#event-based-activation-behavior-and-limitations

from office-js.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on August 10, 2024

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

from office-js.

microsoft-github-policy-service avatar microsoft-github-policy-service commented on August 10, 2024

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.

from office-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.