Set Table DV fields to readonly based on field value
Posted: 2019-04-12 18:59
Hello All,
I have read numerous posts where users would like to see a record lock once a certain state is achieved. I have read and understand there are certain complexities and complications that can arise from this. I have a similar need but think it can be met if the right circumstances are enabled. If a field has a positive value, a checked check box then the detail view for the table row becomes read only based on a JS file. I have tired to use some code I found on this forum but have been struggling with it. I would like to call my check box something like Done or Closed. If it checked all the fields named would become read only:
function setFieldAsLabel(array_field_selector){
var myfields = ["Field1","Field2","Field3"];
var arrayLength = array_field_selector.length;
setFieldAsLabel(myfields);
for (var i = 0; i < arrayLength; i++) {
var $field = $j('#'+array_field_selector);
if ($j('#'+array_field_selector+'-container').length != 0) {
$j('#'+array_field_selector+'-container').select2('enable', false);
$j('#'+array_field_selector+'-container').parent().find('button').hide();
} else {
$j('#'+array_field_selector).prop('readonly', true);
$j('#'+array_field_selector).prop('tabIndex', -1);
$j('#'+array_field_selector).prop('style', 'cursor: not-allowed; background-color: #EEE;');
$j('#'+array_field_selector).mousedown(function(){return false;});
}
}
}
I know this can of course be circumvented but most users likely won't have the skill/knowledge necessary to do that. I also will have previous read only fields that will log the last user editing the record. Thoughts? Did I make sense?
I have read numerous posts where users would like to see a record lock once a certain state is achieved. I have read and understand there are certain complexities and complications that can arise from this. I have a similar need but think it can be met if the right circumstances are enabled. If a field has a positive value, a checked check box then the detail view for the table row becomes read only based on a JS file. I have tired to use some code I found on this forum but have been struggling with it. I would like to call my check box something like Done or Closed. If it checked all the fields named would become read only:
function setFieldAsLabel(array_field_selector){
var myfields = ["Field1","Field2","Field3"];
var arrayLength = array_field_selector.length;
setFieldAsLabel(myfields);
for (var i = 0; i < arrayLength; i++) {
var $field = $j('#'+array_field_selector);
if ($j('#'+array_field_selector+'-container').length != 0) {
$j('#'+array_field_selector+'-container').select2('enable', false);
$j('#'+array_field_selector+'-container').parent().find('button').hide();
} else {
$j('#'+array_field_selector).prop('readonly', true);
$j('#'+array_field_selector).prop('tabIndex', -1);
$j('#'+array_field_selector).prop('style', 'cursor: not-allowed; background-color: #EEE;');
$j('#'+array_field_selector).mousedown(function(){return false;});
}
}
}
I know this can of course be circumvented but most users likely won't have the skill/knowledge necessary to do that. I also will have previous read only fields that will log the last user editing the record. Thoughts? Did I make sense?