The way the script was written, the custom fields don't get populated until after the page is created, by design. This web service requires you to select a person in a "people picker" field, then when you tab off of the field, it fires off the call to the web service. After the 5.1 update this doesn't work any longer either in the "quick create" or just the standard windowed create screen.
The code for the custom field.
<script type="text/javascript" src="http://webprod4.mutualofomaha.com/JIRAIntService/js/JIRAIntService.js">
</script>
<script type="text/javascript">
var updater = new com.mutualofomaha.ldap.LdapUpdater();
updater.pageLoad('reporter', {'customfield_10652': ['employeeOperation'], 'customfield_10653': ['employeeDivision']});
updater.populateFields('reporter', {'customfield_10652': ['employeeOperation'], 'customfield_10653': ['employeeDivision']});
</script>
The javascipt that is called:
var com = {};
com.mutualofomaha = {};
com.mutualofomaha.ldap = (function namespace(){
var fieldMap = {};
function LdapUpdater(){
this.fieldMap = fieldMap;
}
LdapUpdater.prototype.pageLoad = function pageLoad(triggerField, fieldMaps){
// Handler for .ready() called.
//call the service for page load with no change.
var triggerFieldId = triggerField;
var fieldMaps2 = fieldMaps;
connectToService(triggerFieldId, fieldMaps2);
}
LdapUpdater.prototype.populateFields = function populateFields(triggerField, fieldMaps){
AJS.$('#'+triggerField).change(function(){
var triggerFieldId = triggerField;
var fieldMaps2 = fieldMaps;
connectToService(triggerFieldId, fieldMaps2);
});
AJS.$('#'+triggerField).blur(function(){
var triggerFieldId = triggerField;
var fieldMaps2 = fieldMaps;
connectToService(triggerFieldId, fieldMaps2);
});
}
function connectToService(triggerFieldId, fieldMaps) {
fieldMap[triggerFieldId] = fieldMaps;
var triggerFieldValue = AJS.$('#'+triggerFieldId).val();
AJS.$.ajax({
//url: "http://webprod4.mutualofomaha.com/EntLDAPRestService/home/getLdapAttributes/" + triggerFieldValue +".json",
url: "http://webprod4.mutualofomaha.com/JIRAIntService/home/getPSAttributes/" + triggerFieldValue +".json",
dataType: "jsonp",
data: {trigger:triggerFieldId},
jsonp : "callback",
jsonpCallback: "com.mutualofomaha.ldap.updateField",
contentType: "text/json"
});
}
return {LdapUpdater: LdapUpdater, updateField: function updateField(returnData) {
var ldapPerson = returnData["1"];
var triggerField = returnData["2"];
var fieldMapsInstance = fieldMap[triggerField];
AJS.$.each(fieldMapsInstance, function(key, value){
var concattedVals = "";
var count = 0;
AJS.$.each(value, function(index, propertyVal){
if (count == 0) {
concattedVals = ldapPerson[propertyVal];
} else {
concattedVals = concattedVals + " " + ldapPerson[propertyVal];
}
count = count+1;
})
AJS.$('#'+key).val(concattedVals);
});
}};
}());
This code has worked fine until the upgrade.
Hi, there were changes to how Javascript works from JIRA 4.4 to JIRA 5.x.
Refer to https://developer.atlassian.com/display/JIRADEV/Custom+Fields+that+use+CSS+or+JavaScript+Web+Resources+in+JIRA+5.0 for more information on the changes.
In particular, you need to change the function to:
<script type="text/javascript"> function action() { } action(); JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context) { action(); }); </script>
Harry,
Sorry for the delay. It worked. many Thx... mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.