
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 06:18 AM
I have a sn-choice-list as such:
Which shows me list of countries.
<sn-choice-list sn-model="c.cmp_country" id="cmp_country" name="cmp_country" placeholder="${Company Country}" field="country" sn-options="data.cnt" sn-value-field="value" sn-text-field="label" sn-items="data.cnt" page-size="10" required></sn-choice-list>
How to i fetch the value selected in server script ?
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 11:32 PM
Change it as below, and add ".toString()" while getting the value from a GlideRecord [cnt.sys_id.toString()].
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 07:57 AM
Hi,
you can try this out,
Add sn-on-change="c.valueSelected(selectedValue)" in HTML as below:
<sn-choice-list sn-model="c.cmp_country" id="cmp_country" name="cmp_country" placeholder="${Company Country}" field="country" sn-options="data.cnt" sn-value-field="value" sn-text-field="label" sn-items="data.cnt" page-size="10" sn-on-change="c.valueSelected(selectedValue)" required></sn-choice-list>
Client Script:
//add this in your client script
c.valueSelected = function(selectedValue)
{
c.data.selectedCountry = selectedValue;
c.server.update();
}
Server script:
// finally you can check if input is provided or not and access it as below in server script
if(input)
gs.addInfoMessage(input.selectedCountry);
Hope this solves the issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 08:53 AM
No this does not work. The client script is throwing error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 09:17 AM
Could you add a screenshot showing the script and also a screenshot of the error

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2021 09:57 PM
gs.addInfoMessage(input.selectedCountry);
gives me output: [object object]
when i print the value in client side there also getting the same output:
c.valueSelected = function(selectedValue) {
c.data.selectedCountry = selectedValue;
alert(c.data.selectedCountry);
};
i am getting the object instead of the exact selected value