Alexandru
Alexandru

Reputation: 12892

How can I change this input's value?

I want to change the input of a text field that stores the subject line in the Outlook Web App using JavaScript:

enter image description here

This subject text field is defined as:

<input tabindex="0" class="_f_ql _f_rl textbox allowTextSelection placeholderText" role="textbox" aria-labelledby="MailCompose.SubjectWellLabel" autoid="_f_B2">

I have tried the following using my JavaScript code:

textFieldElement.value = "Example";
textFieldElement.innerHTML = "Example";
textFieldElement.innerText = "Example";

These work to set the value as far as the user interface is concerned:

enter image description here

But they don't modify the "real" value of the subject that gets posted when you hit Send. Once you hit the Send button, the subject takes on no value (and shows up as (no subject) in an email). I can see from the POST request that unless I manually click on the element, focus it, and manually type in what I want it to display, physically with the keyboard, it won't send the subject argument in its JSON object.

enter image description here

How can I modify the "real" subject value that this control is expected to handle? I'm guessing this is an MVC control or some other type of ASP.NET control...and I am trying to modify the .aspx page, with JavaScript, to edit this value.

------------------------------------------------------------------------------------------------------------------------------------------------

Edit: I have only been able to set the subject line in one specific case. First, I need to physically click on the subject element. I've noticed this has a strange behavior of setting the class on this element from this:

<input class="_f_ql _f_rl textbox allowTextSelection placeholderText" autoid="_f_B2" role="textbox" tabindex="0" aria-labelledby="MailCompose.SubjectWellLabel">

To this:

<input class="_f_ql _f_rl textbox allowTextSelection" autoid="_f_B2" role="textbox" tabindex="0" aria-labelledby="MailCompose.SubjectWellLabel" maxlength="255">

Once it is in the non-placeholderText state with maxlength = "255", I am able to successfully change the innerText on it using textFieldElement.innerText = "Example";, and on submit, this gets sent correctly.

However, I cannot assume that the Subject element will ever be clicked, so I must work with the placeholderText version of the subject element first and somehow get it to reproduce this behavior where it goes into the other state. So far, I have tried the following without success:

Upvotes: 0

Views: 185

Answers (1)

Sterling Archer
Sterling Archer

Reputation: 22395

http://msdn.microsoft.com/en-us/library/office/fp161027(v=office.1501401).aspx

Looks like you need to use

Office.context.mailbox.item.subject to set the subject. Outlook uses an API, so you need to use the API methods.

Upvotes: 1

Related Questions