- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 06:10 PM
Stockroom -> alm_stockroom
Consumable -> alm_consumable
i tried to use this qualifier on the consumable but i kept getting everything not the one specified to the selected stock room
javascript: "install_status=6^stockroom=" + current.getValue('stockroom');
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 07:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 07:16 PM
@chercm It is a custom field change your reference qualifier to this.
javascript : "install_status=6^stockroom=" + current.u_stockroom;
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 08:42 PM
Hi @chercm
What I understood is you are expecting to deduct the stock when a Catalog Task is closed.
Try creating a business rule like the one below.
Name: Deduct asset quantity from stock
Table: sc_task
Advanced: True
When to Run Section:
When: After
Insert: True
Update: True
Conditions:
Asset :: is Not Empty
Stock Room :: is Not Empty
State :: Changes to :: Closed Complete
Advanced Section:
Script:
(function executeRule(current, previous){
var almGr = new GlideRecord('alm_asset');
almGr.addQuery('sys_id', current.u_reference_1);
almGr.query();
if(almGr.next()){
var quantity= almGr.getValue('quantity');
var req_quantity= current.request_item.quantity;
try{
quantity = quantity - req_quantity;
if(quantity >= 0){
almGr.setValue('quantity', quantity);
almGr.update();
} else{
gs.addErrorMessage('Available quantity is less than the requested quantity, unable to update the stock.');
}
}catch(ex){
gs.addErrorMessage('Unexpected Error:' + ex.message);
}
}
}
)(current, previous)
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 08:42 PM
Hi @chercm
What I understood is you are expecting to deduct the stock when a Catalog Task is closed.
Try creating a business rule like the one below.
Name: Deduct asset quantity from stock
Table: sc_task
Advanced: True
When to Run Section:
When: After
Insert: True
Update: True
Conditions:
Asset :: is Not Empty
Stock Room :: is Not Empty
State :: Changes to :: Closed Complete
Advanced Section:
Script:
(function executeRule(current, previous){
var almGr = new GlideRecord('alm_asset');
almGr.addQuery('sys_id', current.u_reference_1);
almGr.query();
if(almGr.next()){
var quantity= almGr.getValue('quantity');
var req_quantity= current.request_item.quantity;
try{
quantity = quantity - req_quantity;
if(quantity >= 0){
almGr.setValue('quantity', quantity);
almGr.update();
} else{
gs.addErrorMessage('Available quantity is less than the requested quantity, unable to update the stock.');
}
}catch(ex){
gs.addErrorMessage('Unexpected Error:' + ex.message);
}
}
}
)(current, previous)
Please mark my answer helpful and accept as solution if it helped you 👍✅
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 09:10 PM
i am trying to create a ritm form but what should i enter as the field : what should be displayed and store on the catalog builder ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 09:25 PM
@chercm In general it should be better to use reference fields for this kind of scenario. Which will display Display name of the consumable but store the actual reference, I mean sys ID of the record which will be useful for future reference.
But if your requirement is for just a select box with choices you can choose the Display Name (display_name) field for better User Experience.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 09:44 PM
@AnveshKumar M @Danish Bhairag2
i tried to create RITM form using catalog builder but it is not what i was looking for. how can i design the form with the request name - sys_users and the item requested from alm_consumable and submit button. It should create ritm form and sctask for the assigned team
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 09:49 PM
Hi @chercm ,
You can create both the fields as a Reference field. Where requestor can select the values which they wish for. Then u can create a flow designer & attach it to your catalog item under process engine tab. Flow designer should include a step for creating a task which will be assigned to the specific team.
Thanks,
Danish