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

DavidPetty
Archer Employee
Archer Employee

@mintyalex can you post the custom object code you're using?

 Advisory Consultant

DavidPetty
Archer Employee
Archer Employee

@mintyalex I received the custom object code.

First you do not need to wrap the custom object in <html></html> tags.  Archer inserts the custom object inside the existing DOM.

Once I cleaned that up, I had no problems setting a record permission field to the current user with the field that was hidden.

 Advisory Consultant

mintyalex
Contributor III

Thanks David - I will give your recommendation a go.

Apologies for the long winded way of sending the code to you. As I mentioned Archer would not let me upload it directly here.

Alex

Hi @DavidPetty ,

I have tried your suggestion - tidied up the code and removed the HTML tags - very good to know, thanks!

However, the hidden (or read only) record permissions field is being set - up until the record reverts to "view" mode when it restores the original value. The same issue for assigning or unassigning.

Thanks,

Alex

Are seeing any errors in the developer tools console when you click either button?

 Advisory Consultant

Hi @DavidPetty  - again, my apologies for the late reply. 

No errors on the button click. The record permission field does not save the change when the record reverts to view. It updates the VL, saves the record and changes the record permission name - but when you press view, the Record Permission field value goes back to blank.

mintyalex
Contributor III

tagging @BJJohnson  for visibility as per request from Summit. 

I made some change to the function to set the record permission field.  I suggest that you add parameters so you can re-use the function for both setting and clearing the record permission field.

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

          // Push user details into the array in the appropriate format
          UsrArray.push({
               name: setUserConfig.usersName,
               value: setUserConfig.usersId + ':' + (setUserConfig.itemType == 'group' ? 3 : 1)
          });

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

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

          var usersGroups = $CM.getFieldControl($CM._fields[setUserConfig.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(setUserConfig.usersName);
          }
     }

 Advisory Consultant

Thank you @DavidPetty - this function works perfectly. I dont suppose you have a function to clear the value within the record permission field? I have two buttons, one assigns and the unassigns. The other button is experiencing the same behaviour, it clears it in Edit mode but when the record is returned to view mode, it returns it back to the original value.