- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 08:44 AM
I have a requirement to create the multiple records automatically when the ticket is created.
Ticket : RITM
I have used a UI action to create the record automatically at the hardware table and it works for single record
But now I have a requirement to create multiple records when quantity is more than 1
example when someone submits the catalog request, if they select quantity as 5 then system needs to create 5 records for the same
I have sample script here for UI action which copies the variable value and maps to table field when UI action is clicked
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 09:10 AM
Hi @Thrupthi1 ,
Try script like below.
var quantity=current.quanity;
for(var i=0;i<quantity;i++)
{
var asset = new GlideRecord("alm_hardware");
asset.initialize();
asset.asset_function = "testing";
asset.location = current.variables.destination_location;
asset.insert();
}
If my answer resolves your issue then don't forget to mark it as correct/helpful.
Regards,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 08:54 AM
To be clear, you want multiple, separate RITMS for EACH hardware request?
The best way to do this is adjust the specific catalog item(s) to have not have the "enable cart" attribute selected...this will force the user to order one at a time for that particular item, from the SP (like how your UI action works).
If you want the "convenience" of a cart, with the "robustness" of an individual RITM for each of this type of hardware request, you're going to be "chasing your tail" in my opinion.
Think about the user experience (let alone the level of code/customization which would be required) if someone orders 5 of these items (call it "Hardware request") and 2 others which don't have this restriction...which action would you want ServiceNow to take, when they checkout?
> Create 5 RITMs, one with the 2 others, 4 with only a Hardware Request? Does it matter which one gets the "others"?
> Create 5 RITMs, one with only the 2 "others"?
> Create 7 individual RITMs?
When my organization went live initially (Istanbul), we set up some customized cart functionality as the catalog builder didn't exist and we didn't have attributes oob to disable cart functionality on some items, but not others...and it is a big "maintenance headache" now. I'd strongly recommend utilizing the base functionality in the catalog builder, to ensure these specific hardware requests do not group into a single RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 09:02 AM
Hi jMarshal
Thank you so much for the reply it was really helpful information.
But this request is used only for test device management and fulfiller teams raise them up.
But when they select bulk request for example 5quantity they will only create for one single type of asset
Example 1: Laptop - model same - manufacture same
2:Laptop - model same - manufacture same
3:Laptop - model same - manufacture same
4: Laptop - model same - manufacture same
5: Laptop - model same - manufacture same
Everything will be same expect the serial number which they get information later on
So their requirement is they fill the information in one single form and raise one 1 RITM with 5 quantity, interms system should create 5 record for the same
Isnt this not possible to achieve! or do you still think its not a best practice to do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 09:06 AM - edited ‎05-25-2023 09:36 AM
Ahhhhh, that makes more sense. I misunderstood the problem a little bit.
I didn't know you were having an issue with asset table inserts, I thought it was with the RITM itself.
Could you show a screenshot of your catalog item? Are you using the build-in cart "quantity" feature on your SP or is this a custom variable on the RITM?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2023 09:10 AM
Hi @Thrupthi1 ,
Try script like below.
var quantity=current.quanity;
for(var i=0;i<quantity;i++)
{
var asset = new GlideRecord("alm_hardware");
asset.initialize();
asset.asset_function = "testing";
asset.location = current.variables.destination_location;
asset.insert();
}
If my answer resolves your issue then don't forget to mark it as correct/helpful.
Regards,
Devender