cancel
Showing results for 
Search instead for 
Did you mean: 

Custom object for setting value list of type people and group

SonamSingla
Contributor III

I am trying to set field A value which is of type value list and getting values fro User Group.

Field A = User A, User B, User C, User D from some GroupBasedOnRole

 

Now based on some condition need to set value of field A to 

if field B = ABC then field A should be set to User A

if field B = XYZ then field A should be set to User B

 

In case i use this code 

<script>
var integration = {
fieldID:"16179",
valueID:"240",
};
var valueArray = new Array(1);
valueArray[0] = integration.valueID;
ArcherTech.UI.GenericContent.GetInstance().setFieldValue(integration.fieldID, valueArray, '');
</script>

How can i get value ID for that particular user.

pastedImage_1.png

53 REPLIES 53

Hi Ilya how can we use global variables means in case i want to hard code value of value list column getting values from Group.

No, in your case you do not use Global variables, check my 1st post. Global variables would be useful for getting logged current user.

Hi Ileya

Aggregating ur posts am able to achieve this. but still it is not working. Cn you please help

<script>
Sys.Application.add_load(function() {
alert($CM.getFieldValue('16179'));
var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById('16179');
var RPFieldRootId = RPFieldRoot.clientId;
var valListFieldAttributes = new Array();
valListFieldAttributes.push({
text: "Jose, Nirmal",
value: "240:1",
selected: "true"});
var valListFieldAttributesSerialised = Sys.Serialization.JavaScriptSerializer.serialize(valListFieldAttributes[0]);
$('input[id*="'+ RPFieldRootId +'"]').val("Jose, Nirmal");
$('input[id$="'+ RPFieldRootId +'c_ClientState"]').val(valListFieldAttributesSerialised);
});

</script>

I cannot really understand whole meaning of the code, but try to use some cleaner version, e.g. from David:

Custom Object to Set User/Group Popup Field 

https://community.rsa.com/thread/192522 

Hi Ilya,

 

I tried ths  but it is givng error -Cannot read property 'clientId' of undefined

 

 

<script type_="text/javascript">
var setUser = {
fldId: '16179',
usersName: 'John, Smith',
usersId: '240',
itemType: 'user'};

var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];
var RPFieldRootId = RPFieldRoot.clientId;
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);
</script>

You have probably defined wrong field id.

No it is right Ileya

Use this in EDIT mode:

<script type="text/javascript">
     var setUser = {
          fldId: '16179',
          usersName: 'Smith, John',
          usersId: '240',
          itemtype: 'user'};
 
     function setRecordPermission() {
          var RPFieldRoot = ArcherTech.UI.ClientContentManager.GetInstance().getFieldById(setUser.fldId), UsrArray = [];

          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() {
          setRecordPermission();     
     });

</script>