Create Multiple RITMs Under Same REQ Using the UI Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 06:25 AM
Hi All,
I have a UI Action that runs on the alm_hardware table. When assets are selected and the button is clicked, it submits the RITMs based on the number of assets selected, with each RITM associated with the REQ. Below is the script used to achieve this:
var configId = current.ci.sys_id;
var cartId = GlideGuid.generate(null);
var wasteCart = new Cart(cartId);
var item = wasteCart.addItem('bc94067c978516144c913b6e6253af41', 1);
wasteCart.setVariable(item, "u_item_ewaste", configId);
wasteCart.setVariable(item, "u_previous_state", current.install_status);
var rc = wasteCart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery('cat_item=bc94067c978516144c913b6e6253af41^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^variables.7cbe614b97091a104c913b6e6253af81=' + configId);
ritm.orderByDesc("created");
ritm.query();
if (ritm.next()) {
current.install_status = 500;
current.update();
} else {
gs.log("RITM not created hence status is not changed for serial number: " + current.serial_number, 'eWaste Logs');
}
Now, I have a requirement: when the user selects 10 assets in the table and clicks the button, it should create 10 RITMs under a single REQ. Please let me know how this can be achieved.
Regards,
Priya
- Labels:
-
Asset Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 09:52 PM
Hello Priya,
I might try like below,
Create a function(selectedAssets). Iterate through this list of selected Assets, create a RITM and associate it to the same Request. Please let me know if you need more help.
Please mark it helpful, if it helps you in start working on it.
BR,
Suman.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:35 AM
Hi @SumanKumarM
Thank you for your response. If possible could you please help me with the sample script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 06:41 PM
Hello Priya,
I hope below sample code might help you to complete your task.
Please mark it helpful, if my sample code helps you in anyway.
BR,
Suman.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 08:46 PM
Hi @SumanKumarM ,
Thank you! But I would like to know how to retrieve the list of selected assets using a UI action in the list view.
For example, when a user selects assets in the list view and clicks the created UI button, it should submit RITMs under the same REQ.
Regards,
Priya
