Custom widget to have a multi selector dropdown field on Service Portal

Dennis17
Tera Guru

Hi colleagues.

 

I need to build a multi selector field where the dropdown choices list is created with REST response on Service Portal (inside catalog item).

For select box variables it's easy, you can create a catalog client script to call an ajax script, get REST response and then, use g_form.addOption() to include response as choices.

For list collector variable it's not possible because a reference to table is mandatory.

So after that, I'm trying to create a custom variable where choices are created with REST response, a dropdown list is displayed and multiple choices can be selected.

I followed this article but it didn't work: https://www.servicenow.com/community/developer-articles/sn-record-picker-service-portal-for-multisel...

Has anyone done anything similar? or could you support me?

 

Thanks in advance.

1 ACCEPTED SOLUTION

Soeren Maucher
Mega Sage

Hello @Dennis17

 

I am not sure about you UI/UX requirements, but in theory you could consider using a Multi Row variable set which has a select box where you apply the mentioned logic. This way you can populate/ limit the choices based on your ajax script logic, and the user can still select multiple ones. 

From a pure technical point of view this would be the cleanest solution to achieve your requirement in my opinion without "hacking" your own custom variable. However, I could imagine that form UI/UX it might be little bit more complicated. 

 

I hope this helped. If yes, I would appreciate if you could mark this answer as "correct solution" or give a thumbs up. Thank you!
Greetings,
Sören

 

View solution in original post

2 REPLIES 2

Soeren Maucher
Mega Sage

Hello @Dennis17

 

I am not sure about you UI/UX requirements, but in theory you could consider using a Multi Row variable set which has a select box where you apply the mentioned logic. This way you can populate/ limit the choices based on your ajax script logic, and the user can still select multiple ones. 

From a pure technical point of view this would be the cleanest solution to achieve your requirement in my opinion without "hacking" your own custom variable. However, I could imagine that form UI/UX it might be little bit more complicated. 

 

I hope this helped. If yes, I would appreciate if you could mark this answer as "correct solution" or give a thumbs up. Thank you!
Greetings,
Sören

 

Hi Soeren,

 

Thanks for that idea, it could be a solution.

I will continue to work on my first proposal because it would be the 'perfect' one but once again, thanks!

 

Best regards.

Denis