Set Table DV fields to readonly based on field value

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
kbarrett
Veteran Member
Posts: 50
Joined: 2019-02-24 16:35
Location: Calgary Alberta

Set Table DV fields to readonly based on field value

Post by kbarrett » 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?

pkumar
Posts: 4
Joined: 2021-05-01 22:52

Re: Set Table DV fields to readonly based on field value

Post by pkumar » 2021-05-17 05:38

Dear Sir

wiil you please guide me which file i have to past this code,
i am new to AG.
in my AG i want this to be implemented

User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Set Table DV fields to readonly based on field value

Post by aarlauskas » 2021-05-21 20:37

Hi, I needed this and done in the following scenario. Created (Required) drop-down field at the bottom of the detail view (named “Report Status”) with two values: Incomplete & Complete. Created random user (Named Locker..). Then code in hooks that monitors the value of the Report Status field, basically when users enter the data, they are required to select Report Status. If they select status ‘Complete’ and save, the code in hooks changes ownership of the record to this random user ‘Locker’. Then based on user permissions, they are only able to edit/delete their own record, but can only see the record that belongs to ‘Locker’. . Well you have an idea. I did this of course with the help of the chaps on this forum..

Post Reply