The CreatorCon Call for Content is officially open! Get started here.

stories

pragadeesh254
Tera Contributor

As a platform owner, I want to be to able to create story from an enhancement record AND
when 
story is created, 
if story state -> draft, enhancement state -> scoping
story state -> ready, enhancement state - > work in progress
story state -> cancelled, enhancement state - > cancelled
story state -> complete, enhancement state - > complete

9 REPLIES 9

Hello @pragadeesh254,

 

There must be a field called 'Original Task' or 'Parent'. So you can use that field's backend value in the script that I have provided in my previous reply to complete your requirement.

 

If above answer resolve your issue, Please mark the solution as 'Accepted Solution' and Also mark it as 'Helpful'.

 

Thank You!

Prathamesh.

AnveshKumar M
Tera Sage
Tera Sage

Hi @pragadeesh254 

If you want a no code approach, you can create a flow like the one below.

 

1. Flow properties.

AnveshKumarM_0-1703660901828.png

 

2. Trigger conditions

AnveshKumarM_3-1703661407031.png

 

3. Create Flow Logic and Corresponding Update Actions 

AnveshKumarM_4-1703661477869.png

AnveshKumarM_5-1703661502417.png

 

AnveshKumarM_6-1703661529519.png

 

AnveshKumarM_7-1703661542434.png

 

AnveshKumarM_8-1703661556052.png

 

AnveshKumarM_9-1703661569211.png

 

AnveshKumarM_10-1703661582304.png

 

AnveshKumarM_11-1703661595491.png

 

The final completed flow would be like this,

AnveshKumarM_12-1703661627938.png

 

AnveshKumarM_13-1703661639934.png

 

AnveshKumarM_14-1703661655502.png

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

 

 

Thanks,
Anvesh

AnveshKumar M
Tera Sage
Tera Sage

@pragadeesh254 You can create an After - Insert/Update BR like the one below.

 

AnveshKumarM_0-1703662201204.png

 

 

AnveshKumarM_1-1703662229486.png

Note: Sate is one of Draft, Ready, Completed, Cancelled

 

(function executeRule(current, previous /*null when async*/) {

	var enhancement = current.getValue("enhancement") + '';
	var enGr = new GlideRecord("rm_enhancement");
	if(enGr.get("sys_id", enhancement)){
		if(current.state == '-6'){
			enGr.setValue("state", "-4");
		} else if(current.state == '1'){
			enGr.setValue("state", "2");
		} else if(current.state == '3'){
			enGr.setValue("state", "3");
		} else if(current.state == '4'){
			enGr.setValue("state", "7");
		}
		enGr.update();
	}

})(current, previous);

 

AnveshKumarM_2-1703662277597.png

 

Please mark my answer helpful and accept as a solution if it helped 👍 ✔️

 

Thanks,
Anvesh

pragadeesh254
Tera Contributor

when i create new story there is a state field in the when i click draft then the enhancement state should be scoping but there is no enhancement field

Prathamesh G
Kilo Sage

Hello @pragadeesh254,

 

You can create an UI action on the Enhancement table to create the story. Below is the attached code where you can create the UI action for Creating a story from the enhancement record.

Prathamesh_0-1703666318870.png

 

UI Action -

createStory();

function createStory() {

  // (1) Copy Enhancement fields into a new story
  var story = new GlideRecord("rm_story");
  story.priority = current.priority;
  story.short_description = current.short_description;
  story.assignment_group = current.assignment_group;
  story.assigned_to = current.assigned_to;
  story.description = current.description;
  story.work_notes = current.work_notes;
  story.type="Development";
  story.opened = current.opened;
  story.opened_by = current.opened_by;
  story.product = null;
  story.state = getNewState(current);
  story.insert();

  // (2) Redirect webpage to the new story (Ensure story displayed in scrum view)
  gs.addInfoMessage(gs.getMessage("Story {0} created", story.number)); 
  action.setRedirectURL(story);
  var redirectURL = action.getRedirectURL();
  redirectURL = redirectURL.replace("sysparm_view=", "sysparm_view=scrum");
  action.setRedirectURL(redirectURL);
  action.setReturnURL(current);
}

 

And you can create a After > Update Business Rule on the Story [rm_story] table with the Condition as 'State Changes'.

And in the Advanced section, you can add the below code to set the its related enhancement record's state.

(function executeRule(current, previous /*null when async*/ ) {

    if (current.state == 'draft') { //always take the backend value for the choices
        current.enhancement.state = 'scoping'; //use the dot-walk functionality to update the related enhancement record of the story.
    } else if (current.state == 'ready') {
        current.enhancement.state = 'work in progress';
    } else if (current.state == 'cancelled') {
        current.enhancement.state = 'cancelled';
    } else if (current.state == 'complete') {
        current.enhancement.state = 'complete';
    }

})(current, previous);

 

If above answer resolve your issue, Please mark the solution as 'Accepted Solution' and Also mark it as 'Helpful'.

 

Thank You!

Prathamesh.