How to right click on Task and convert to a Story

Cory Hitchings
Giga Guru

Hi all, 

Wondering if there's a way to convert a Task to a Story from right clicking and selecting from a menu?  

We currently have this configured for Incidents for Outages, Changes, Problems.   Any ideas on how to achieve this at the sc_task level to convert to a rm_story? 

find_real_file.png

 

Thank you very much in advance! 

 

 

3 REPLIES 3

jarodm
Mega Guru

Since your screenshot is from the UI (not Portal or Agent Workspace), I'll assume you want the solution to this in the UI as well.

Take a look at these highlighted UI Actions on the Incident table. Create a new UI Action on the Catalog Task table, and add some conditions so that at only shows up for people with the right role, for the right catalog items.

Update the script to create a new Story (instead of an Outage), copying over as much information as you need from the current record to the story record.

If you'd like to take any action on the current Catalog Task, do that here too. I recommend at least adding the new STRY number to the SCTASK work notes, possibly even closing out the SCTASK. UI Actions are one of the places it's okay to do a current.update(), so don't feel bad about using that here.

Set a redirect record, and redirect to the new STRY, if desired.

 

 
action.setRedirectURL(storyGR);
action.setReturnURL(current);

Optional: Set a gs.addInfoMessage('Story created from this task') if desired.

Good luck, have fun!

 

JarodM

Cory Hitchings
Giga Guru

Hi all, 

If any one is interested, you create UI Action on the Task table using this code: 

var story = new GlideRecord("rm_story");
story.initialize();
story.u_requested_for = current.request_item.request.requested_for;
story.short_description = current.short_description;
story.description = current.description;
story.priority = 4;
story.state = -5;
story.insert();

action.setRedirectURL(story);

Thanks for sharing Cory. I wanted to share a similar requirement I developed earlier this year.

The difference includes adding the incident or the requested item in the related list, as we use this for defects or enhancements, respectively.

 

createStoryM2M();

function createStoryM2M() {
	
	var table = current.getRecordClassName();
	
  //Update saves incidents before going to the catalog homepage
	current.update();
	var story = new GlideRecord("rm_story");
	story.initialize();
	story.cmdb_ci = current.cmdb_ci;
	story.assignment_group = current.assignment_group;
	story.assigned_to = current.assigned_to;
	story.short_description.setDisplayValue(current.number + " - " + current.short_description);
	story.description.setDisplayValue(current.description);
	
	if(current.priority == '5'){
		story.priority = '4 - Low';
	} else {
		story.priority = current.priority;
	}
	
	switch(table) {
		case 'incident': {
			story.business_analyst = current.u_affected_customer;
			story.classification = 'Defect';
			break;
		}
		case 'sc_req_item': {
			story.business_analyst = current.request.requested_for;
			story.classification = 'Feature';			
		}			
	}
	
	var storyID = story.insert();
	
	// add m2m relation from incident to story
	if(current.getRecordClassName()=='incident') {
		var m2mstoryINC = new GlideRecord("u_m2m_stories_incidents");
		m2mstoryINC.initialze();
		m2mstoryINC.u_incident = current.sys_id;
		m2mstoryINC.u_story = storyID;
		m2mstoryINC.insert();
		
	// add m2m relation from sc_req_item to story
	} else if (current.getRecordClassName()=='sc_req_item') {
		var m2mstoryRITM = new GlideRecord("u_m2m_stories_requested_items");
		m2mstoryRITM.intialize();
		m2mstoryRITM.u_requested_item = current.sys_id;
		m2mstoryRITM.u_story = storyID;
		m2mstoryRITM.insert();
		
		action.setRedirectURL(story);
		gs.addErrorMessage('Please add the approriate product.');
	}
}