Create an RITM when Idea is accepted. Catalog item is hidden in the Employee Center.

Vaishnavi35
Tera Guru

Hi,

 

I have built a catalog item with its workflow. Its hidden in Employee Center for users to submit.

When an Idea is accepted , I want the RITM to be created with the Idea values that were submitted. Mapping the values basically. I want the Demand Number also on the RITM form. 

Demand Number field exists on the Idea form.

 

If anyone can help me with the BR?

Idea - Label and Name 

Vaishnavi35_0-1717694041366.png

 

RITM - Question & Name -

Vaishnavi35_1-1717691927797.png

Idea values have to map to the ritm variables.

 

I have an existing BR that creates a Demand when Idea is accepted.

When- before condition ; On "Update"

 

 

var demandTable = "dmn_demand";
if(GlidePluginManager.isActive('com.snc.project_management_v3')){
	demandTable = SNC.PPMConfig.getDemandTable(current.getTableName());
}

var demand = new GlideRecord(demandTable);
demand.setValue("description", current.description);

demand.setValue("requested_by", current.u_required_completion_date_if_any);//requested_by


demand.setValue("portfolio", current.u_global_process_shared_services_area);
demand.setValue("portfolio", current.portfolio);
demand.setValue("primary_program",current.u_program);
demand.setValue("priority", current.priority);

demand.setValue("short_description", current.short_description);
demand.setValue("type", "project");
demand.setValue("submitter", current.submitter);
demand.setValue("parent", current.sys_id);
demand.setValue("idea", current.sys_id);
var dmnId = demand.insert();
demand.get(dmnId);
current.demand = dmnId;
current.stage = 'demand';
GlideSysAttachment.copy('idea', current.sys_id, 'dmn_demand', demand.sys_id);
var link = ' <a href ="/' + demandTable + '.do?sysparm_query=number%3D' + demand.getValue('number') + '">'+ demand.getValue('number') +'</a>';
var message = gs.getMessage("Demand {0} has been created");
message = message.replace("{0}", link);

gs.addInfoMessage(message);

 

 

 

When Idea is accepted Demand and RITM should be created. But in RITM , Demand Number should also be populated.

Thanks,

Vaishnavi 

11 REPLIES 11

Joseph Charlie
Tera Contributor

Use Flow Designer, with a trigger that monitors for an update on the Idea table. Once the Idea is updated, update the RITM as needed. You can also add a wait condition for the RITM to update the Idea once the RITM is closed.

I am not familiar with Flow Designer, if there is anyway you can help?

 

I would want a wait condition for Demand number to populate on Idea form and then RITM to be created with all the Idea fields and values including the demand Number.

From Left Nav Open Flow Designer>New>provide a name.

 

Trigger>Updated

Table> name of the table that contains Idea

Condition> (I used Task is not empty)

Run Trigger> Once

Trigger.png

Actions> Update Record

Record>sys_id of the task record created

Table> sc_req_item or what ever table contains your RITM

Fields> update the fields needed you can use info from the idea table to write to the description field. 

Ex. Work note = Ritm Created from Idea {pill} Trigger-Record Updated>Idea Record>Short Description.

Update other fields as needed.

Step 1.png

Add Wait For Condition {My use case was to wait till the RITM is closed}

This will cause the flow to pause until the RITM is updated.

Step 2.png

Update Record>Trigger-Record Updated (Idea)

Table (idea table)

Fields: State = Completed

Close Notes = {pill} Update Record>Requested Item Record>Work notes

Step 3.png

Step 4.png

SasankaV
Mega Guru

Hi @Vaishnavi35 , I have faced a similar situation in the past. I considered some of the below steps to overcome it:

 

Ensure the catalog item and its workflow are properly configured.
Make sure it’s hidden in the Employee Center but accessible programmatically.
Extend the existing Business Rule to create the RITM when an Idea is accepted.
Map the Idea values to RITM variables.
Include the Demand Number on the RITM form.

 

var demandTable = "dmn_demand";
if(GlidePluginManager.isActive('com.snc.project_management_v3')){
demandTable = SNC.PPMConfig.getDemandTable(current.getTableName());
}

// Create the Demand
var demand = new GlideRecord(demandTable);
demand.setValue("description", current.description);
demand.setValue("requested_by", current.u_required_completion_date_if_any);
demand.setValue("portfolio", current.u_global_process_shared_services_area);
demand.setValue("portfolio", current.portfolio);
demand.setValue("primary_program", current.u_program);
demand.setValue("priority", current.priority);
demand.setValue("short_description", current.short_description);
demand.setValue("type", "project");
demand.setValue("submitter", current.submitter);
demand.setValue("parent", current.sys_id);
demand.setValue("idea", current.sys_id);
var dmnId = demand.insert();
demand.get(dmnId);
current.demand = dmnId;
current.stage = 'demand';
GlideSysAttachment.copy('idea', current.sys_id, 'dmn_demand', demand.sys_id);
var link = ' <a href ="/' + demandTable + '.do?sysparm_query=number%3D' + demand.getValue('number') + '">'+ demand.getValue('number') +'</a>';
var message = gs.getMessage("Demand {0} has been created");
message = message.replace("{0}", link);
gs.addInfoMessage(message);

// Create the RITM
var ritmGr = new GlideRecord('sc_req_item');
ritmGr.initialize();
ritmGr.cat_item = 'your_catalog_item_sys_id'; // Replace with your catalog item sys_id
ritmGr.short_description = current.short_description;
ritmGr.description = current.description;
ritmGr.requested_by = current.u_required_completion_date_if_any; // Update this field if necessary

// Map Idea values to RITM variables
ritmGr.variables.your_variable_1 = current.idea_field_1; // Replace with actual field mappings
ritmGr.variables.your_variable_2 = current.idea_field_2; // Replace with actual field mappings
// Add more mappings as needed

// Include Demand Number on RITM
ritmGr.variables.demand_number = demand.number;

var ritmId = ritmGr.insert();

 

Identify and note down the sys_id of the catalog item you want to use.
Ensure it has variables that match the Idea fields you want to map.
Extend your existing Business Rule to include the creation of the RITM.
Use `GlideRecord` to create a new RITM record and map the necessary fields from the Idea.
Ensure the RITM variables are correctly mapped to the corresponding Idea fields.
Add the Demand Number to the appropriate variable on the RITM.
Accept an Idea and verify that both Demand and RITM are created.
Check that the RITM contains the mapped Idea values and the Demand Number.
Test different scenarios to ensure all mappings work as expected.
Adjust the script as needed based on testing results.

Give these steps a try and let me know if it doesn't work. I'd be happy to assist.