{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":31859,"path":"it-service-management/change-management/t_CreateNewUIAction.md","title":"Create a UI action","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a UI action\n\nCreate a UI action to display a button on a change request for the **Complete** state.\n\n## Before you begin\n\nRole required: admin\n\n## About this task\n\nThe UI action must contain a condition that uses the state model script include to decide when the **Complete** button is displayed on the Change Request form. In this case, the **Complete** button is displayed only when the change has reached the **Implement** state.\n\n## Procedure\n\n1.  Open the **Change Request** form.\n\n2.  Open the form context menu and select **Configure** &gt; **UI Actions**.\n\n3.  Locate and open the existing **Implement** UI action.\n\n4.  Open the form context menu and click **Insert and Stay** to create a duplicate record.\n\n5.  Modify the following fields with new values.\n\n<table id=\"table_mpc_zd1_4v\"><thead><tr><th>\n\nField\n\n</th><th>\n\nValues\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nComplete.\n\n</td></tr><tr><td>\n\nAction name\n\n</td><td>\n\nstate\\_model\\_move\\_to\\_complete.\n\n</td></tr><tr><td>\n\nHint\n\n</td><td>\n\nProgresses change to Complete state.\n\n</td></tr><tr><td>\n\nOnclick\n\n</td><td>\n\n`moveToComplete();`.\n\n</td></tr><tr><td>\n\nCondition\n\n</td><td>\n\ngs.hasRole\\('itil'\\) &amp;&amp; new ChangeRequestStateHandler\\(current\\).isNext\\(\"**complete**\"\\)\n\n</td></tr><tr><td>\n\nScript\n\n</td><td>\n\nUpdate function, state name, and state value.```\nfunction moveToComplete(){\n                  var ga = new GlideAjax(\"ChangeRequestStateHandlerAjax\");         \n                  ga.addParam(\"sysparm_name\", \"getStateValue\");         \n                  ga.addParam(\"sysparm_state_name\", \"complete\"); \n                  ga.getXMLAnswer(function(stateValue) {              \n                      g_form.setValue(\"state\", stateValue);              \n                      gsftSubmit(null, g_form.getFormElement(), \"state_model_move_to_complete\");         \n                  });\n          } \n          if (typeof window == 'undefined')   \n             setRedirect(); \n\n          function setRedirect() {   \n              current.update();   \n              action.setRedirectURL(current);\n          }\n```\n\n.\n\n</td></tr></tbody>\n</table>6.  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 model script include](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/change-management/t_UpdateStateModelScriptInclude.md)\n\n**Next topic:**[Create a process flow record](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-service-management/change-management/t_CreateNewProcessFlowRecord.md)\n\n"}}