For Generated RITMs the Workflow is not getting Attached

naren19
Giga Guru

Hi @Ankur Bawiskar / @Ravi Gaurav  /  @Dr Atul G- LNG 
Could you please help on this

Based on the Request Type Entries the RITM's needs to be generated
For Example,
Suppose if the Request Type has two entries in Request then RITM need to be create Two RITM with Attached Workflow.
Currently i am using below script but the Workflow is not getting attached to the Generated RITMs

var requests = JSON.parse(current.u_scratchpad);

for (var i = 0; i < requests.length; i++) {

    var dns1 = requests[i];

    var ritm1 = new GlideRecord('sc_req_item');
    ritm1.initialize();
    ritm1.cat_item.setDisplayValue('DHCP Reservation-RITM');
    ritm1.workflow.setDisplayValue('RITM-DHCP Reservation');
    ritm1.assignment_group.setDisplayValue('SERVER.WINTEL.GLBL.IM.SUP');
    ritm1.short_description = 'DHCP Reservation ' + dns1.request_type;
    ritm1.parent = current.sys_id;
    ritm1.request = current.sys_id;
    ritm1.u_scratchpad = JSON.stringify(requests[i]);
    ritm1.opened_by = current.requested_for;
    ritm1.comments = '[code]<table ng-if = "records.length > 0" class = "table table-striped table-bordered table-hover" cellspacing = "0" width = "100%"><thead><tr><th>Request Name</th><th>Details</th></tr></thead><tbody><tr>' + dns1.html + '</tr></tbody></table>[/code]';

    var ritm_sys_id = ritm1.insert();
}