Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2023 11:09 AM
Hello Experts,
I have two variables on my catalog item named "Replace Asset"[List collector variable] and "Reason for replacement"[choice type variable]with two choices lost and broken. In Replace Asset user can select which asset he wants to replace. if the user selects 3 assets for replacement and the reason for replacement is lost then I want to create an incident for that request. on the incident form, I want to populate the affected CI for the incident which is primary
for example: If I select 3 assets for replacement that is Asset A, Asset B, and Asset C on the incident form for the affected CI field I want to populate Asset A which is primary. and other CIs I want to show in the affected CI-related list on the incident form. can anyone please guide me on this how can I achieve this?
thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2023 07:08 PM
Hi @Mark Wood
Are you using Record Producer or Catalog Item?
If you are using a record producer, you can use the record producer script to achieve this otherwise you can do it in Flow Designer or Workflow.
var cis = producer.replace_asset; //Your Replace Asset variable name
cis = cis.split(',');
var task = current.getUniqueValue();
if(cis.length >= 3 && producer.reason_for_replacement == 'lost'){
current.cmdb_ci = cis[0];
for(var i = 1; i < cis.length; i++){
var gr = new GlideRecord('task_ci');
gr.task = task;
gr.ci_item = cis[i];
gr.insert();
}
}
If you are using a Flow for your catalog item,
1. Get the catalog variables using Get Variables action.
2. Create a flow variable for number of CIs.
3. Assign flow variable with the size using inline script.
4. Check the Size of CIs and Reason in if logic and if it is true,
4a. Create Incident record using Create Record Action.
4b. Use for each flow logic and create record action to insert records in to task_ci table for the rest of the CIs
Please mark my answer helpful and accept as a solution if it helped 👍✅
Anvesh