how to Add a state to the change state model

suprakash
Giga Expert

I added two states draft and work in progress as the   process given in   Add a state to the change state model

in my case the first step is draft and second state will be work in progress after that there are other states

i have to do in a way that from draft the state will only be updated to work in progress. After it comes to work in progress then it may go to another state for . this is emergency change request type

But i cannot understand how to edit the script include ChangeRequestStateModel_emergency.

Need help

1 ACCEPTED SOLUTION

Hi Suprakash,



'Review' is a OOB Change request state, so you do not have to define 'canMove' or 'moving' function separately for review. In your case the code will below:



work_in_progress: {


              nextState: [ "review" ],


             


              review: {


                      moving: function() {


                              return this.toReview_moving();


                      },


                     


                      canMove: function() {


                              return this.toReview_canMove();


                      }


              },



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

23 REPLIES 23

amlanpal
Kilo Sage

Hi Suprakash,



If you have to add new states to Change request form, all you have to follow the below 3 links one by one.



1. You need to create new state choices, which I hope you already have done. Still for your reference I'm providing here Create a new choice


2. You need to update the state handler script include accordingly. You can find the guiding document here Update state handler script include


3. At last you need to update the state model script include for all types (considering you want to show the state in every types). Please find the related document here Update state model script include



Just for your information you need to define work in progress state as the nextState in your corresponding state model script include (mentioned in step 3). For example:


draft: {


              nextState: [ "work_in_progress" ],


             


              work_in_progress: {


                      moving: function() {


                              return this.toWorkInProgress_moving();


                      },


                     


                      canMove: function() {


                              return this.toWorkInProgress_canMove();


                      }


              }


      },



Also you need to add below lines in the corresponding script include along with above code.


toWorkInProgress_moving: function() {
   
return true;
   
},    

  toWorkInProgress_canMove
: function() {    
   
return true;    
   
},



Just for extended information, if you need to define any UI Action based on the newly created state choices, you may refer this: Create new UI action



I hope this helps.Please mark correct/helpful based on impact



Thanks Amlan,


I tried in the way you suggested and its working.


But i tried the same thing for other states that time its not working.


Suppose   now my current state is work in progress and now it only can be moved to review .


i did the same thing as before



work_in_progress: {


              nextState: [ "review" ],


           


              review: {


                      moving: function() {


                              return this.toreview_moving();


                      },


                   


                      canMove: function() {


                              return this.toreview_canMove();


                      }


              }


      },




toreview_moving: function() {
   
return true;
   
},    

  toreview_canMove
: function() {    
   
return true;    
   
},




But this time its not working and when i tried to change the state from work_in_progress to review its giving invalid update.




I checked by giving error message for the first case the function is getting called that is from draft to work_in_progress



But for next case the function is not getting called.....................




Waiting for your reply


Hi Suprakash,



'Review' is a OOB Change request state, so you do not have to define 'canMove' or 'moving' function separately for review. In your case the code will below:



work_in_progress: {


              nextState: [ "review" ],


             


              review: {


                      moving: function() {


                              return this.toReview_moving();


                      },


                     


                      canMove: function() {


                              return this.toReview_canMove();


                      }


              },



I hope this helps.Please mark correct/helpful based on impact


Hi suprakash,



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.


If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View