Forum Discussion
Hello,
You can achieve this by running code like the sample below in an onFormPopulated event on your form where this xClass field exists.
var nameOfXClassField = "xclass"; // <-- Change this to be the name of the field in your form
// Disable the ability to add additional xClass relationships
var xClassEllipses = getFieldByName(nameOfXClassField).getElementsByClassName("aras-field-xclasses-ellipses")[0];
xClassEllipses.style.pointerEvents = 'none'; // disable the ability to click on this button
xClassEllipses.children[0].style.backgroundColor = '#b3b3b3'; // change the color of the button
// Disable the ability to delete the xClass relationship
// We have to do this inside of a timeout because these buttons are loaded after this form event is called
setTimeout(function() {
var xClassDeleteButtons = getFieldByName(nameOfXClassField).getElementsByClassName("aras-field-xclasses__delete-cross");
for (var i = 0; i < xClassDeleteButtons.length; i++)
{
var deleteButton = xClassDeleteButtons;
deleteButton.parentElement.removeChild(deleteButton);
}
}, 1000); // <-- You should play around with this value to find the minimum amount of time you need to wait based on your environment
Chris
Christopher Gillis
Aras Labs Software Engineer