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-10-2023 11:13 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