Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object to make a field "invisible" to end users

mintyalex
Contributor III

Slightly odd request here - but I have a CO that populates the current user into a user values field when a button is clicked.

However, it only works when the field is visible on layout and NOT hidden by Rules/Actions DDEs.

I have also tried to make it Read Only - and it will populate the field but the field will revert when it goes back to View mode from Edit.

I do not want users to be  able to edit this field - and the only workaround I can think of is to make it visually invisible but where Archer can still read and edit it.

Is it possible to "hide" an entire field via a Custom Object but in such a way that Archer could still see it?

12 REPLIES 12

This is a great idea, any luck on the above from yesterday from mintyalex @DavidPetty 

@GionlucaMallia as I mention, reuse the setRecordPermission function by adding a parameter for the user array.

Something like this:

 

var userToPopulate = {
               name: setUserConfig.usersName,
               value: setUserConfig.usersId + ':' + (setUserConfig.itemType == 'group' ? 3 : 1)
          };

var userToClear = {
               name: "",
               value: "")
          };

setRecordPermission(12334, userToPopulate);

setRecordPermission(12334, userToClear);

function setRecordPermission(fldId, user) {
          // Obtain the field root by ID and initialize user array
          var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(fldId),
               UsrArray = [];
          var RPFieldRootId = RPFieldRoot.clientId;

          // Push user details into the array in the appropriate format
          UsrArray.push(user);

          //Serialize and set values in the UI
          var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);
          $('div[id*="' + RPFieldRootId + '_"] div:first-child').text(user.name);
          $('input[id*="' + RPFieldRootId + '_"]').val(serialized);

          // Set appropriate hidden field based on item type
          if (setUserConfig.itemType == 'user') {
               $('#SelectedUsers' + fldId).val(user.value.split(':')[0]);
          } else if (setUserConfig.itemType == 'group') {
               $('#SelectedGroups' + fldId).val(user.value.split(':')[0]);
          }

          var usersGroups = $CM.getFieldControl(fldId)
          var tree = $find(usersGroups.get_treeViewId());
          tree.set_popupValue(UsrArray);
          
          // Check if the field is read-only and update the UI accordingly 
          var layoutItem = $LM.getLayoutItemById(RPFieldRoot.layoutId);
          if (layoutItem && layoutItem.display == ArcherTech.Enums.LayoutItemActionType.ReadOnly) {
               $('#'+RPFieldRootId).closest('tbody').find('.rtMid').text(user.name);
          }
     }

 

 Advisory Consultant

Hi @DavidPetty 

Thanks for your inputs. I have tried to do as suggested but setting it as a blank using something like the below: 

    function removeRecordPermission() {
        // Configuration for assigning a "blank" user
        var unassignUserConfig = {
            fldId: '32168',
            usersName: "", // Blank name
            usersId: "",  // Blank ID
            itemType: 'user' // Use 'group' if adding a group
       
        }; 
 
does not work. It clears the field, but when saved it reverts back. I thought it was an issue with how it is written, but when I specify an actual user, it saves and works fine. The only alternative I can think of is to use a user called "Not Assigned" or something, but that isnt ideal.