Create an RITM when Idea is accepted. Catalog item is hidden in the Employee Center.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 07:19 AM - edited 06-06-2024 10:14 AM
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
RITM - Question & Name -
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 08:10 AM
Hi @SasankaV ,
If you can help me with the code please? the variables section is not visible at all.
Thanks,
Vaishnavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 11:23 AM
CreateRequest();
function createRequest() {
// Create Request
var cart = new Cart();
// Substitute your catalog item
var item = cart.addItem('389e052687e20e909e70c91acebb351f');
// Set Variables in your Cart Item
item.u_project_name = current.short_description;
item.u_project_description = current.description;
item.u_cost_center_c = current.u_cost_center; // Update this field if necessary
item.u_portfolio_c = current.portfolio;
item.u_program_c = current.u_program;
item.u_requested_for = current.u_requested_for;
item.u_manager = current.u_requested_for.manager;
item.u_request_made_by = current.submitter;
item.variables.u_demand_number = current.demand.number;
// Update the item
item.update();
// Place the order
var rc = cart.placeOrder();
gs.addInfoMessage('Request Item Created: ' + rc.number);
// Start the workflow
var w = new Workflow();
var wfSysId = w.getWorkflowFromName("Business Unit Project RITM").dc1ff6cc873e4210ed64da473cbb3513;
var operation = "start"; // Assuming you want to start the workflow
w.startFlow(wfSysId, current, operation);
}
My updated code. RITM itself is not getting created now.