in Education by
I am having problems with the event handler in my office addin . Below is an example code i got from microsoft website to explain what i mean. I have a manifest file that uses the on-send hook as well as a click-based event triggering. My button calls appendMessageBodyOnClick and onsend i call appendMessageBodyOnSend. Both function primarily do the same thing. I never want to block sending emails regardless. The problem is that the event object is not properly cleaned up i think. Scenario 1 When i click my button ; which calls event.completed(), and then after i try to send the message, it says my app is blocking the message, but then when i try to send again it goes through. Scenario 2 When i leave the subject empty and then send the message, as expected i am prompted that the subject is empty. If i cancel sending the message on this note and then click on my button, the message tries to send as though i clicked send. I am supposing the is some sort or state clean up issue. What am i doing wrong here? Function-File.js function appendMessageBodyOnClick(event) { // Append string to message body event.completed(); } // In the following example, the checkMessage function has // been registered as an event handler for ItemSend. function appendMessageBodyOnSend(event) { // Append string to message body event.completed({allowEvent = true}); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Not sure if this will help, but I also have faced some seemingly inconsistent behavior while understanding how to signal that event is fully completed. Once I got my edge cases fixed, then it worked. One suggestion: Appending string to message body should be an async function. Call the event.completed() from inside the callback function. (i.e: make sure when you are calling event.completed(), nothing else is pending -like another async result) Something like the following: Office.context.mailbox.item.body.setAsync("new body", function(asyncResult) { // handle success and failure event.completed() }); Same would be for your scenario 2, make sure event.completed() is called at the very end.

Related questions

0 votes
    This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Closed 9 years ago. Possible Duplicate: PHP: unformat money How to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    How To Clean Up Your Amazon Ec2 Instance And Volume ?...
asked Mar 12, 2021 in Technology by JackTerrance
0 votes
    Why initialize and clean up in object studio is necessary in Blue prism?...
asked Nov 6, 2020 in Technology by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I use some UserControls which get created and destroyed within my application during runtime (by creating and ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I use some UserControls which get created and destroyed within my application during runtime (by creating and ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I use some UserControls which get created and destroyed within my application during runtime (by creating and ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    What is the function used to deregister event handler f'? (a) deleteAllListeners(name) (b) deleteListener( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
0 votes
    In general, event handler is nothing but ____________ (a) function (b) interface (c) event (d) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
...