cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Object for Record Permission set value

AkshayDaniel
Contributor III

Hi All,

 

This query is regarding the solution provided in post Custom object for setting value list of type people and group .

 

Our requirement is that we need to empty the values in manual record permission field in Archer 6.4 

 

The code written for it based on the solution available in the post mentioned earlier is 

 

<script type="text/javascript">
     var setUser = {
          fldId: '39845',
          usersName: 'Daniel, Akshay',
          usersId: '2528',
          itemtype: 'user'};
 
     function setRecordPermission() {
          var RPFieldRootId = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];
          console.log(RPFieldRootId);
         
          UsrArray.push({
               name: setUser.usersName,
               value: setUser.usersId
          });  
          var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray);

          $('div[id*="'+ RPFieldRootId +'_"] div:first-child').text(setUser.usersName);
          $('input[id*="'+ RPFieldRootId +'_"]').val(serialized);
          if(setUser.itemType == 'user'){
               $('#SelectedUsers'+setUser.fldId).val(setUser.usersId);
          }
     }

     Sys.Application.add_load(function() {
          alert('script loaded');
          setRecordPermission();    
     });

</script>

 

Here initially I tried to set a value just to check if the code is working in our environment but unfortunately it does not.

 

While doing some troubleshooting I figured that the selectors  mentioned below do not point to anything could be the reason for not updating the value.

$('div[id*="'+ RPFieldRootId +'_"] div:first-child')
$('input[id*="'+ RPFieldRootId +'_"]')

 

I tried to add some additional information so that the selectors are able to pick up the required elements

 

$('div[id*="'+ RPFieldRootId.clientId +'_"] div:first-child')

 

The above code does select something although not sure if that is the correct element value and does not even update the field properly.

 

Kindly advise what corrections are required in my code and also please let me know if I need to empty the values from this manual record permission field can I just pass "".

2 REPLIES 2

Ilya_Khen
Champion III

I run that code pretty well in many environments.

1. Do you run Custom Object in Edit mode?

2. Try to change your RP to ValuesPopup type.

 

Try this:

<script type="text/javascript">
     var setUser = {
          fldId: '39845',
          usersName: 'Daniel, Akshay',
          usersId: '2528'
            };
 
    function setUser(userFldId, userName, userId) {
          var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(userFldId), UsrArray = []; 
          var RPFieldRootId = RPFieldRoot.clientId; 

          UsrArray.push({ 
               name: userName, 
               value: userId + ':1' 
          }); 
         
          var serialized = Sys.Serialization.JavaScriptSerializer.serialize(UsrArray); 
         
          $('div[id*="'+ RPFieldRootId +'_"] div:first-child').text(userName); 
          $('input[id*="'+ RPFieldRootId +'_"]').val(serialized); 

          $('#SelectedUsers'+userFldId).val(userId);
     } 

     Sys.Application.add_load(function() {
          alert('script loaded');
          setUser(setUser.fldId, setUser.usersName, setUser.usersId);    
     });

</script>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

DavidPetty
Archer Employee
Archer Employee

Akshay, in order to clear a record permission field you'd have to modify the setUser variable and just set the usersName and usersId to nothing, ''.

 

Like so:

var setUser = {
     fldId: '39845',
     usersName: '',
     usersId: '',
     itemtype: 'user'
};

 Advisory Consultant - Archer, an RSA Business