Hi,
I have used third part code and it is working fine for our requirement. I found a bug need to fix on the code.
Issue is, Option-Set field is not getting saved even after pick from the list. each time when opening a record it change back to normal. Is there a way to do it ?
Please help & code is below also have mention the link from where i got this code.
function FireChangeEventsOnLoad(attributeNames){
// Validate the arguments passed to the function
// attributeNames expects string of format: "new_field|name|description"
if (typeof attributeNames !== 'string')
throw new Error('attributeNames must be a string of attribute names');
// Get array of attribute names to fire onchange event
var attributes = attributeNames.split('|');
// Create empty array to hold errors
var attributesNotOnForm = [];
// Loop through the attribute names and fire onchange event if available
for (var index = 0; index < attributes.length; index++) {
var attributeName = attributes[index];
var attribute = Xrm.Page.getAttribute(attributeName);
if (attribute === null) {
attributesNotOnForm.push(attributeName);
continue;
}
attribute.fireOnChange();
}
// If there are errors then display alert dialog
if (attributesNotOnForm.length > 0)
Xrm.Utility.alertDialog('Could not find the following attributes on the form: \n' + attributesNotOnForm.join(',\n'));
}
function ToggleTabOnValue(eCxt, tabName, optionValue) {
// Validate the arguments passed to the function
if (typeof eCxt !== 'object' || typeof eCxt.getEventSource !== 'function')
throw new Error('Event Context has not been passed');
if (eCxt.getEventSource().getAttributeType && eCxt.getEventSource().getAttributeType() !== 'optionset')
throw new Error('attributeType is not optionset. Event can only be registered on an optionset');
if (typeof tabName !== 'string')
throw new Error('tabName must be the name of a Tab');
if (typeof optionValue !== 'string')
throw new Error('optionValue must be the Text value of an OptionSet');
// Get Attribute that triggered event
var eventAttribute = eCxt.getEventSource();
// Get Tab to Show/Hide
var tab = Xrm.Page.ui.tabs.get(tabName);
if (tab === null)
throw new Error('The given tabName does not exist on the form. tabName == ', tabName);
// Show Tab if Text matches, otherwise hide it.
if (eventAttribute.getText() === optionValue)
tab.setVisible(true);
else
tab.setVisible(false);
}
www.c2software.com/.../using-javascript-library-to-show-or-hide-a-tab-based-on-optionset-value.aspx









