How can I create a demand from a Catalog request?

nicolemccray
Tera Expert

I'm not at all familiar with the Demand Module, and I'm trying to determine how I can map a Catalog Request to a Demand.   Wondering if anyone has some references or scripts that will help.

6 REPLIES 6

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI Nicole,



Do you want a OOB way or do you want a script to be build. I have a script which allows you to show how demand can be created.



Thank you,
Ashutosh


I would prefer a script.   What I would like to do is when a user hits 'submit' on a Catalog Item, that it generates a Demand with the same fields and data.


You can configure workflow script for your catalog item workflow and use below run script as sample   in your workflow to generate demand







var demandTable = "dmn_demand";


if(GlidePluginManager.isActive('com.snc.project_management_v3')){


demandTable = SNC.PPMConfig.getDemandTable(current.getTableName());


}




var demand = new GlideRecord(demandTable);


demand.initialize();


var fields = ['business_case', 'short_description', 'submitter', 'sys_domain', 'business_unit', 'department', 'impacted_business_units', 'business_capabilities', 'business_applications'];


for(var i in fields){


var field = fields[i];


if(demand.isValidField(field)){


demand.setValue(field, current.getValue(field));


}


}




demand.setValue("category","strategic");


demand.setValue("type", "project");


demand.setValue("parent", current.sys_id);


demand.setValue("idea", current.sys_id);




if(GlidePluginManager.isActive('com.snc.apm')){


demand.setValue("size", current.effort);


if(current.pm_program)


demand.setValue("primary_program", current.pm_program);


if(current.start_by_fiscal_year)


demand.setValue("start_date", new GlideDateTime(current.start_by_fiscal_year.fiscal_start_date_time).date);


if(current.implement_by_fiscal_year)


demand.setValue("requested_by", new GlideDateTime(current.implement_by_fiscal_year.fiscal_end_date_time).date);



var demandPrice = parseFloat(current.estimated_benefit.getReferenceValue());


demand.setValue("financial_benefit",   current.estimated_benefit.getReferenceCurrencyCode() + ';' + demandPrice);


}




var dmnId = demand.insert();


demand.get(dmnId);


current.demand = dmnId;


current.stage = 'demand';


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);


Thank you for the reply.   I will look into this once my form is complete.