This script is a shell to have a particular project default to a particular "from" mailbox address when replying. This code uses the Project ID, but you can switch to using the MAILBOX the case came into instead. See below for the change.
name: Default the 'from' mailbox for certain project(s)
description: Automatically change the 'from' address when on a particular project.
author: Sonny Kim
version: 1.0.0.0
js:
$(function(){
// if we're not on the case page, don't do anything
if (!$('#bugviewContainer').length) return;
var arrForThisProject = new Array();
var arrUseThisMailbox = new Array();
// ******* YOU MUST EDIT THIS SECTION *******
// need a project to mailbox mapping. Add elements to the arrays for more projects - mailbox pairings.
arrForThisProject[0] = '2'; // for this ixProject number
arrUseThisMailbox[0] = '"some name" <some@mailbox.com>'; // use this mailbox (find this value by inspecting the from element in reply page and finding the 'select' value options
// ******* END SECTION *******
var setTheFromMailboxAddress = function () {
for (var i = 0; i < arrForThisProject.length && i < arrUseThisMailbox.length; i++) {
if (window.goBug.ixProject == arrForThisProject[i]) {
$('#sFrom option[value*="' + arrUseThisMailbox[i] + '"]:first').attr('selected','selected');
}
}
DropListControl.refresh($('#sFrom')[0]);
}
var myFunction = function(sCommand) {
if ($('div.body.editable .emailHeader').length < 1) return;
setTheFromMailboxAddress();
};
if ($('#sEventEdit').length > 0)
{
myFunction('new');
}
else
{
myFunction('load');
}
// run it when the view changes and pass in the new view:
$(window).on('BugViewChange', function(e, data) {
myFunction(data.sCommand);
});
});
If a case is in a given project, you may want to use the code above to reply from a specific address. If you don't care about the current project and want the reply set based on what address they emailed YOU at, you can change the above from using goBug.ixProject to using goBug.ixMailbox. Email us with questions.