how to empty the sn record picker value
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2023 11:14 PM
Hello All,
I have a custom widget with select box using sn-record-picker.. However, the selected/ chosen value still stays whenever the Modal opens. The requirement is to empty the value every time the Modal opens.
Observation: The field populates correctly but if I do not submit the Modal instead cancel it or close it and open it for the second time(without refreshing the page) the username does not clear out. It stays with the last chosen username value. I want that to be emptied in such instances.
HTML
<div class="row"> <div class="col-xs-6"> <div class="form-group"> <label for="firstname"><b>User Name</b></label> <sn-record-picker field="c.addUsr.firstname" table="'sys_user'" default-query="data.existUserid" display-field="'name'" display-fields="'email'" value-field="'sys_id'" search-fields="'name,email'" page-size="100" > </sn-record-picker> </div> </div> <div class="col-xs-6"> <div class="form-group"> <label for="email"><b>Email</b></label> <input type="text" placeholder="Enter Email" class="form-control" name="email" disabled required ng-model="c.addUsr.email1"> </div> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary" style="color:white;" ng-click="c.addExistinguser(n)" data-dismiss="modal">Submit</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div>
Client
c.addExistinguser=function(n){ c.data.user = {value: c.data.user.name, displayValue:c.data.user.sys_id}; c.data.action = 'addexistingUser'; c.data.exUser = c.addUsr; //console.log(c.addUsr); //console.log(n); //c.closeexistingUserform(close); c.server.update().then(function(){ c.getUserlist(); }); } //Onload function to populate values $scope.$on("field.change", function(evt, parms) { //console.log(parms.newValue); c.data.usersysid = parms.newValue; if(parms.newValue =='') { c.addUsr.email1 = ''; c.addUsr.title = ''; c.addUsr.busiphone = ''; c.addUsr.timezone =''; } else{ c.data.action = 'fetchexistingUser'; c.server.update().then(function(){ c.addUsr.email1 = c.data.existingUser[0].email; c.addUsr.busiphone = c.data.existingUser[0].busphone; c.addUsr.title = c.data.existingUser[0].title; c.addUsr.timezone =c.data.existingUser[0].time_zone; }); } });
@Shubham Shinde @Ankur Bawiskar @BharathChintala @Community Alums
0 REPLIES 0