ALERT! The community will be read-only on April 19, 8am Pacific as the migration begins. Read more for important details.
ALERT! The community will be read-only on April 19, 8am Pacific as the migration begins.Read more for important details.
Absent Member.
Absent Member.
1268 views

Multi-Relational or Multi-Selection field AddChangeCallback not useable


I am looking to make multi-relational field have a proper On Change ability. Currently the AddChangeCallback for multi type fields does not run unless the user clicks the right box after putting a value there. This is quite unintuitive and is quite useless for multi relational type fields. So my question is, has anyone figured out a way to have a javascript to detect change when either person double clicks on a value from the left box or if they use the arrows to change values in the right box. Any help will be appreciated, thanks.
0 Likes
6 Replies
Absent Member.
Absent Member.


A look into the code shows that it is running the javascript "multiSelectAdd" or "multiSelectRemove" functions on both the arrow and double-click events. You could probably override the original function dynamically in javascript, saving it with a new name and then calling it at the end of a new function that also fires the change event for the field.Before getting that deep though I would check with Support to see if this is something that has already been fixed or is scheduled to be fixed, as it seems like a bug.
0 Likes
Absent Member.
Absent Member.


Thanks for the idea Jeff. I don't think it is a bug as the javascript manual states that the only way to use AddChangeCallback for multi fields is to click on the right box after using arrows or double clicking.I will take a look into your idea. Would you happen to know what the code is for those functions. I don't want to override them and break the normal functionality of the functions.
0 Likes
Absent Member.
Absent Member.


Well, perhaps an enhancement request then.To override, use a technique like the one described here:http://stackoverflow.com/questions/5409428/how-to-override-a-javascript-functionMake sure to call the original function (now renamed) first so that the values are where they should be, before you run your new custom code.
0 Likes
Absent Member.
Absent Member.


Yeah I may just submit that enhancement. Current implementation is not very good.Thanks for the info, I will give it a try later this afternoon.
0 Likes
Absent Member.
Absent Member.


Implemented a solution using Jeff's idea and it works like a charm. So now when you click on the arrows you can have exact on change values for multi value fields right after you add them. Run code on an Load of the form (eg. AddLoadCallback)Example Code://Add overridevar origAdd = multiSelectAdd;multiSelectAdd = function(str1, str2) { origAdd(str1, str2); var multiItemVal = GetMultiListValues("CONTACT_S"); alert(multiItemVal);};//Remove overridevar origRem = multiSelectRemove;multiSelectRemove = function(str1, str2){ origRem(str1, str2); var multiItemVal = GetMultiListValues("CONTACT_S"); alert(multiItemVal);}
0 Likes
Absent Member.
Absent Member.


Here's a complete solution to fire the Change event when adding/removing items from MultiSelect boxes:// Fix issue with MultiSelectAdd/Remove not firing Change events
var multiSelectAdd_orig = multiSelectAdd;
multiSelectAdd = function(id, leftBox, doApf, winRef, fieldRef)
{
multiSelectAdd_orig(id, leftBox, doApf, winRef, fieldRef);
FireChangeEvent(GetFieldByName(id));
}

var multiSelectRemove_orig = multiSelectRemove;
multiSelectRemove = function(id, leftBox, doApf, winRef, fieldRef) {
multiSelectRemove_orig(id, leftBox, doApf, winRef, fieldRef);
FireChangeEvent(GetFieldByName(id));
};
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.