catalog item variable to display quantity of "in stock" assets where the model category is "computer
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 07:33 AM
Hi all,
I need some help to achieve the following in a catalog item:
When a user selects a stockroom from a variable, I would like it to then calculate and display in another field the total quantity of "in stock" assets where the model category is "computer".
I've been browsing the community but cannot find a definitive answer to this.
Please help.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 07:53 AM
Hi,
write onChange client script of selection stockroom variable
Client Script:
var ga = new GlideAjax('CalAssetQuant');
ga.addParam('sysparm_name', 'getQuant');
ga.addParam('sysparm_stockroom', newValue);
ga.getXMLAnswer(function(response) {
g_form.setValue('ENTER ANOTHER VARIABLE NAME', response);
});
script include :
getQuant: function() {
var stockroom = this.getParameter('sysparm_stockroom');
var total = 0;
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('model_category.name=Computer^install_status=6^stockroom='+stockroom); // 6 is in stock state
gr.query();
while (gr.next()) {
total += parseInt(gr.quantity);
}
return total.toString();
},
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 02:21 AM