Outlook Add-in: Knowing how long user has been composing email - outlook-web-addins

In my time-tracking add-in I need to know how long the user has been writing his email. For the READ mode there is dateTimeCreated. But that field does not exist in COMPOSE mode.
What I want:
User writes his email
Before he sends it, he opens the add-in taskpane. The add-in automatically calculates the time the user has been composing the email and shows this time on the screen: like
var time = new Date() - Office.context.mailbox.item.dateTimeCreated
This won't work obviously because dateTimeCreated does not exist in the compose mode, but just so you get the idea...
Any idea on how to achieve this? Some alternatives?

Outlook automatically creates a Draft of any email after a set amount of time. You could set the "automatically save draft" setting to 1 second, then your timer can be based on the time the draft email was created.

Related

Netsuite doesn't trigger user event scripts after Duplicate number screen when saving payment

The problem: When I save the customerpayment in UI it triggers the user event scripts before showing the dialog to change the duplicated transaction number (attached). After I change the number, it doesn't trigger the user events.
How can I catch with my scripts the change of the transaction numbers?
Do you need to be able to manually set (override) the document number for payments? If not the easiest fix would be to go to Setup > Company > Auto-Generated Numbers, select the Document Numbers tab and uncheck the Allow Override option in the relevant row. Then NetSuite will automatically take care of numbering.
changing the Document number may not be triggering you user event script. Can you try editing and saving the record again. If your user event is designed to work on edit, it will get triggered when you edit and save the record.

How to do an iterative email send with breaks for user prompts?

I have VBA code that iterates through emails in an Excel file and populates the bodies of Outlook emails with different criteria that relate to the recipients of the emails.
I want after each automated creation/draft of an email to wait with the draft email open for the user to manually check then send the email. The program would then continue by drafting the next email and prompting the user to check it before sending it.
I am wondering if you can have a While loop within a For loop.
The For loop iterates until all emails have been sent.
The While loop gets its criteria from Outlook. "Did the user send the email? Yes? Draft the next one".
I could not find any resources online. I don't have any code. This question is for directional help. Do you have other suggestions?
What you want to do would be difficult to architect with VBA but not impossible. I would recommend a COM add-in. Regardless, there's no concept of a wait cycle in Outlook that would work in your favor. You will need to maintain a collection of Inspector windows that you add to or remove based on the Inspectors.NewInspector and Inspector.Close events (this is known to Outlook devs as a "wrapper model"). From those Inspector objects you can obtain the MailItem object from Inspector.CurrentItem, and from there you can trap the MailItem.Send event which you can cancel based on user review or proceed to set some internal variables that you can track for managing these send events you're monitoring.
If the wrapper model is too complex, you can just trap single instances of when those events fire, but new windows would fire the event anew and you would lose your "connection" to the item.
For general VBA help, see the Outlook Object Model documentation or OutlookCode.com (old but still relevant).

Changing the email body for transactions sent as a PDF attachment

When a Sales Order is emailed to a customer with Email Preference set to PDF, the body of the email reads:
Please open the attached file to view your Sales Order.
To view the attachment, you first need the free Adobe Acrobat Reader. If you don't have it yet, visit Adobe's Web site http://www.adobe.com/products/acrobat/readstep.html to download it.[/CODE]
I'd like to add onto this message a bit. I think that will require me to write a script that renders the transaction to a PDF template and sends the email with whatever message I choose. It also needs to prevent NetSuite from sending the default email as well.
Would the following work:
In a beforeSubmit function on Sales Order records, if the customer has Email Preference=PDF, uncheck the 'Email To' field. Set a new custom checkbox such as 'Email PDF' to true instead.
In a User Event Script, after a Sales Order submits and has 'Email PDF' set to true, render the transaction to a PDF and send it in an email to all the 'Email To' recipients.
Or is there a better solution I may be overlooking?
The 'duplicate question' says this can't be done yet I have a working solution. It also references SuiteTalk, not the same.
This is a solution someone gave me on the official NetSuite forum:
You can accomplish this fairly easily with a Workflow.
- Trigger on Before Record Submit when 'To Be E-mailed' = T
- Set Field Value of 'To Be E-mailed' = F
- Transition to next state After Record Submit
- Use 'Send Email' action. This allows you to use an email template and
also automatically attach pdf

NetSuite User Event or Workflow on Work Order Close

I looked all over and I can't see to find how to connect a script to the "close" event of the Work Order. Basically, I need to send an email to the Sales Rep for the order that is being fulfilled when the Work Order is "closed" what approach would be better? A workflow or a UserEvent, I looked at workflow as the Close button is a non-standard event. When I went to set up the workflow I didn't see Work Order as a record to attach it to. Any help would be great, thanks
I'm not 100% sure on this, but I'm sure if you did an AfterSubmit User Event, you could get the status of the Work Order. If WorkOrder == 'closed' (whatever the right status is), run your code.
Alternatively, you could build a saved search of WorkOrders that are closed. Run a scheduled script every 15 minutes that will send out an email. Upon sending out the email, tick a checkbox on the WorkOrder to remove it from your Saved Search.
JK, you should be able to build a saved search and use the Alerts feature under the Email tab. Check the box to "Send email alerts when records are created/updated" and enter the recipients in the list under that. If you want it to go only to the Sales Rep for that specific customer, as I assume you do, use the list under 'Recipients from Results' sublist. This means you can have the sales rep returned in the search and choose that field, then the alert will be sent to the relevant rep for each record. You may have to tick the 'Send on Update' option as these records returned by the search will be existing records.
In case you're not familiar with the saved search alerts functionality, the way this works is that as soon as a record of the record type that the saved search is based on meets the conditions specified in the saved search criteria, it fires the alert and emails to the list of recipients specified under 'Specific Recipients' and the result returned by the field specified under 'Recipients from Results.'
What I came to find out is that the Work Order Close status is from a Work Order Close form, in that case just the after submit event takes care of this. Thanks for all your help and sorry I took so long to post this answer

Linking workflow to a custom form in sharepoint

I'm a relatively new sharepoint user using 2007!
I have a built a list, and using designer customised a user input form for completion. The data submitted on the form is built over a period of time and when complete, needs to be used different activities which need to be manually triggered by the user.
My user process is as follows: user completes info on new form at stage one, user updates information and completes information on edit form at step 2 (this step may be repeated if not all data available) which links to a display form to review before submission of workflows. It's from this form I need to link to the workflow initiation screen.
I have 2 x oob approval workflows set on the list, and want to navigate the user from the form to the workflow initiation screen so that they choose which workflow they want to send and when. using one of the list fields, I have populated the URL to this screen for each list ID.
However it has a & within the path so when I try to pull this data through to the form it changes this to &amp, and breaks the link! any idea of how I can work around this?
I would add, I have very little knowledge outside of sharepoint.
& is the html representation of an &, it wouldn't translate in the URL.
When you populate the URL, you can try replacing the & with %26 as that is the ASCII Hex code for &, it may work.
Hope this helps?

Resources