- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 11:35 AM
Hi,
I basically have two fields on the widget ,which is part of the catalog form, and the form will be used in Service Portal. One field is a dropdown (Type) and the second one is a SN Record picker (Item). The record picker is dynamic. The filter changes based on the value selected in the Type field. All these work perfectly fine.
However, when I select a Type, then select and Item. Now going back to select another Type. the previously selected Item is still on display. I want to remove the selected Item after the Type field changes. It sounds simply but how can i achieve this?
I tried to simply empty the variable, didn't work:
$scope.item = {
displayValue: "",
value: "",
name: 'Item'
};
Thanks
Sam
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 12:53 PM
I would suggest changing your controller like this and see if it works:
$scope.loanerItem = {
displayValue: "",
value: "",
name: 'loanerItem'
};
$scope.updateItem = function(){
$scope.loanerItem.displayValue = "";
$scope.loanerItem.value = "";
};

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 11:39 AM
do you have a scope watch setup on your "type" field so that when it changes, you can empty the item with the code you put?
can you post your controller/html from your widget here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 12:03 PM
Hi Jon,
Here is my HTML template:
<div class="form-group col-sm-8">
<label>
Type
</label>
<select ng-model="selectedType" class="form-control" ng-change="updateItem()">
<option ng-repeat="x in c.data.types" value="{{x.value}}">{{x.name}}</option>
</select>
</div>
<div class="form-group">
<label>
Select an Item
</label>
<sn-record-picker field="loanerItem" table="'inventory'" display-field="'u_name'" display-fields="'u_model, u_name'"
value-field="'sys_id'" search-fields="'u_name'" page-size="100" default-query="'u_item=' + selectedType"></sn-record-picker>
</div>
Here is my controller :
function($scope) {
/* widget controller */
var c = this;
$scope.selectedItem = "";
$scope.wItem = {
displayValue: "",
value: "",
name: 'loanerItem'
};
$scope.updateItem = function(){
//this doesn't work
$scope.wItem = {
displayValue: "",
value: "",
name: 'loanerItem'
};
};
}
I stripped down my code quite a bit. I have some other logins in my form. c.data.types does return the records of all Types. I don't post the code for Server Controller because I don't think it is the issue here. Hopefully nothing is missing.
Thank you
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 12:53 PM
I would suggest changing your controller like this and see if it works:
$scope.loanerItem = {
displayValue: "",
value: "",
name: 'loanerItem'
};
$scope.updateItem = function(){
$scope.loanerItem.displayValue = "";
$scope.loanerItem.value = "";
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-08-2018 01:29 PM
Thank you so much!! It does work!!
I am sure I tried something like that but I think I used 'wItem' other than 'loanerItem', as you can see in my original code.
Now my question is: is it important to have the scope variable the same name as the "name" defined in the object? like LoanerItem in my case?
Thanks!
Sam