{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":31869,"path":"it-service-management/change-management/t_UpdateStateModelScriptInclude.md","title":"Update the state model script include","bundle":null,"doc_type":null,"release":"australia","body":"\n# Update the state model script include\n\nUpdate the ChangeRequestStateModel\\_normal script include to add new functions for the **Complete** state.\n\n## Before you begin\n\nRole required: admin\n\n## About this task\n\nYou update the ChangeRequestStateModel\\_normal with the following configuration.\n\n-   Add new *canMove* and *moving* functions for the **Complete** state. These functions can return a value of **true** since there are no special conditions for or extra actions to perform when moving to the **Complete** state.\n-   Modify the definition of the existing object for the **Implement** state to ensure that the next state is **Complete**.\n-   Add an object for the **Complete** state, which defines **Review** and **Closed** as the next two states.\n\n    **Note:** The *canMove* functions for the transition to these states from **Complete** checks the **Needs review** custom field to determine the correct next state.\n\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Definition** &gt; **Script Includes**.\n\n2.  Open the ChangeRequestStateModel\\_normal script include and modify the script as follows.\n\n    1.  Add the following line at the end of the script include but before the line that starts with **type**:\n\n        ```\n        toComplete_moving: function() {\n                      return true; \n                 },              \n        \n                 toComplete_canMove: function() {      \n                       return true;       \n                 },\n        ```\n\n    2.  Modify the existing *implement* object to *toComplete*:\n\n        ```\n        implement: {\n                    nextState: [ \"complete\" ],\n        \n                    complete: { \n                        moving: function() {                \n                            return this.toComplete_moving(); \n                        },             \n        \n                        canMove: function() {                \n                            return this.toComplete_canMove();            \n                        }       \n                    },        \n        \n                    canceled: {  \n                        moving: function() {               \n                           return this.toCanceled_moving();   \n                        },             \n        \n                        canMove: function() {               \n                           return this.toCanceled_canMove(); \n                        }        \n                    }    \n                },\n        ```\n\n3.  Add the following new state object for *complete*.\n\n    ```\n    complete: {\n                 nextState : [ \"review\", \"closed\" ],         \n    \n                 review : {            \n                       moving : function() {\n                             return this.toReview_moving();            \n                       },             \n    \n                       canMove : function() {              \n                              if (this._gr.getValue(\"u_needs_review\") == \"Yes\")   \n                                   return true;                            \n                          \n                              return false;\n                       }        \n                 },                     \n    \n                 closed : {            \n                       moving : function() {  \n                             return this.toClosed_moving();\n                       },             \n    \n                       canMove : function() {              \n                              if (this._gr.getValue(\"u_needs_review\") == \"No\")\n                                   return true;    \n                            \n                      return false;\n                      }       \n                 },  \n    \n                 canceled : { \n                       moving : function() {                \n                             return this.toCanceled_moving();     \n                       },             \n    \n                       canMove : function() {                \n                              return this.toCanceled_canMove(); \n                       }   \n                 }    \n            },\n    ```\n\n4.  Click **Update**.\n\n\n**Parent Topic:**[Tutorial: add a new change management state](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/change-management/t_AddNewStateTutorial.md)\n\n**Previous topic:**[Update the state handler script include](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/change-management/t_UpdateStateHandlerScriptInclude.md)\n\n**Next topic:**[Create a UI action](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/change-management/t_CreateNewUIAction.md)\n\n"}}