Widget Developpement

Rayane Bendahma
Tera Contributor

Hello, I have a quick question.

 

I am developing a widget in Widget Editor. The purpose is to show multiple values in an sn-record-picker by default (with the multiple property set to true).

In my controller script, I have this:

RayaneBendahma_1-1720628051362.png

 

And my sn-record-picker looks like this:

 

RayaneBendahma_2-1720628071919.png

 

It appears that my c.selectedPerson contains the data, but the sn-record-picker does not show it. My sn-record-picker should show a list of users whose sys_id I have specified in my list.

 

The c.selectedPerson array contains objects with the following properties:

  • displayValue: This contains the user's name from c.data.userNamesFin[i].
  • value: This contains the user's sys_id from c.data.userIdsFin[i].
  • name: This also contains the user's name from c.data.userNamesFin[i].

Each sys_id in c.data.userIdsFin corresponds to the respective name in c.data.userNamesFin in the same order.

 

Note: This is a different case from sn-record-picker instances where the multiple property is set to false. Therefore, the solutions provided in other forum posts have not been helpful for my situation.

 

Do you have any idea ?

 

Thank you for any help.

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Rayane Bendahma 

Try the following changes, it worked for me atleast.

 

<sn-record-picker field="selectedPerson" table="'sys_user'" display-field="'name,email'" value-field="'sys_id'" search-fields="'name,email'" page-size="100" multiple="true"></sn-record-picker>

 

Replace your controller script with the following.

var userNamesFinal = c.data.userNamesFin;
var userIdsFinal = c.data.userIdsFin;
$scope.selectedPerson = {
   displayValue: userNamesFinal.join('####'),
   value: userIdsFinal.join(','),
   name: 'selectedPerson'
};

 

Let me know if it is not resolved.

 

Thanks,
Anvesh

View solution in original post

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Rayane Bendahma 

Try the following changes, it worked for me atleast.

 

<sn-record-picker field="selectedPerson" table="'sys_user'" display-field="'name,email'" value-field="'sys_id'" search-fields="'name,email'" page-size="100" multiple="true"></sn-record-picker>

 

Replace your controller script with the following.

var userNamesFinal = c.data.userNamesFin;
var userIdsFinal = c.data.userIdsFin;
$scope.selectedPerson = {
   displayValue: userNamesFinal.join('####'),
   value: userIdsFinal.join(','),
   name: 'selectedPerson'
};

 

Let me know if it is not resolved.

 

Thanks,
Anvesh

Hi @AnveshKumar M ,

Your suggestion worked perfectly and resolved the issue I was facing.

 

I appreciate your help and the time you took to share this solution. It has been immensely helpful for my project.


Thanks,

Rayane

@Rayane Bendahma happy to see it helped you!

Thanks,
Anvesh