So I had a situation where I just HAD to control the message form which isn't supported for client script yet.
In a nutshell:
1) I needed to insert a fax number that wasn't the entities, but rather a child custom record value.
2) Set the subject (and disable the field)
3) Change the entity status
4) Verify required data was present
5) And the really tough one... choose an attachment template from the list.
I wanted to share my solution in case it helps anyone and also ask the pros if there is a better way to do what I did.
I still have a couple of problems to sort out, there is a step or two that I'm missing with setting the drop down list, when I set it, I'm getting an unexpected error upon submitting... more research needed.
When you click the gray 'fax' button on the messages tab it launches a new window. I snooped around the source and found the method that was called, luckily it wasn't in a linked js file.
I added a custom button to the UI and in the click handler launched my own 'fax' window and stored the returned window object for later use.
Because much of the form is dynamically built, you can't start hitting elements until the page is loaded, so I attached an additional 'load' event listener to the stored window object. When this event fires I set the fields I need to in the usual javascript DOM ways.
When it came time to change the selected item in the list I had to do some serious digging, but found out how. There is what looks like a dictionary (I'm not a javascript guy, there may be a better name for it) of all the dynamically generated DropDowns on the page. The dictionary keys are a concatenation of the page wide index of the drop down and the name of the drop as passed to makeDropDown(...).
Once you find your drop down:
var n = 'letter4'; var dropDown = popupWindow.dropdowns[n]; if(dropDown) { dropDown.setValue('10'); } That's it! That will set the selection to the item with the value of '10'.Now I just need to find out what is causing the error I'm getting and I should be god to go The next step is to fire the 'Merge and Send' event. If I can get the last few probs. sorted out I will have a 1-click fax merge. We send out high volumes of entity-status specific faxes, an error by one of our users (sending the wrong document) would be very bad, by automating the process we can really reduce the error potential.With that said, I've INCREASED my headaches as this code will require a lot of maintenance whenever NS changes anything.It would be nice if I could have done something like: popupWindow.nlapiSetFieldValue()...
But it didn't work. If anyone else has any ideas or tips that could make this smoother I would love to hear them.