How to clear value of a 'sn-record-picker' on click of a button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 10:06 PM
I have a sn-record-picker and I have a Clear button. I want to clear the value of sn-record-picker onclick of the button.
I am also using this Clear button to clear the value of other label fields as well.
Code for sn-record-picker:
<sn-record-picker id="contract" name="contract" field="c.loc" table="'country'" display-field="'country.name'" display-fields="'sys_class_name'" value-field="'sys_id'" search-fields="'country.name'" page-size="20" multiple="false" ng-change="cichanged()"></sn-record-picker>
Code for Clear Button:
<input type="button" class="btn btn-primary btn-block text-overflow-ellipsis ng-binding ng-scope button" id="button1" style="width:100px" onclick="myFunction()" value="Clear Data">
<script>
function myFunction() {
document.getElementById("contract").value='';
}
</script>
Could you please help me with this.
Many Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 10:13 PM
where are you using this?
why not use the client controller to clear?
Can you share your complete business requirement for this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 12:08 AM
I am using the sn-record-picker in Angular ng-template which is linked to a widget.
Here I have a Clear button and I'm trying to clear the value entered