{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":27467,"path":"it-business-management/project-management/diagnostic-scripts-form.md","title":"Diagnostic Scripts form","bundle":null,"doc_type":null,"release":"australia","body":"\n# Diagnostic Scripts form\n\nLearn about the fields of diagnostic scripts form.\n\n<table id=\"table_ymh_4kr_wjb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nName of the diagnostic script. Use a name that clearly explains the objective of the script. The script name also enables you to identify the correct script while mapping the script to a feature when creating a diagnostic scan.\n\n</td></tr><tr><td>\n\nDescription\n\n</td><td>\n\nDetails describing the actions of the diagnostic script.\n\n</td></tr><tr><td>\n\nDiagnostic script\n\n</td><td>\n\nThe code for the diagnostic script. The following example shows a diagnostic script to identify tasks with an invalid top portfolio. ```\n/* \n- Inputs can be accessed from scanContext.input as per, the key specified in feature input table.\n\teg.  scanContext.input.projectSysID\n- To pass variables from the one script to another script use varSpace in scanContext.\n\teg.  scanContext.varSpace.variable1 = '...';\n*/\n(function(scanContext) {\n    try {\n        var errorTasks = [];\n        var encodedQuery = scanContext.input.projectFilter;\n        var now_GR = new GlideRecord(\"pm_project\");\n        gr.addEncodedQuery(encodedQuery);\n        gr.query();\n        while (gr.next()) {\n            var entitySysID = gr.getValue(\"sys_id\");\n            var projectData = new ProjectData(entitySysID);\n            var projectTopTaskValidator = new ProjectTopTaskValidator(projectData);\n\n            if (projectTopTaskValidator.tasksWithInvalidTopPortfolioPresent()) {\n                var failedTasks = projectTopTaskValidator.getTasksWithInvalidTopPortfolio();\n                if (failedTasks && failedTasks.length) {\n                    for (var i = 0; i < failedTasks.length; i++) {\n                        errorTasks.push(failedTasks[i].sys_id);\n                    }\n                }\n            }\n```\n\n</td></tr></tbody>\n</table>**Related topics**  \n\n\n[Add diagnostic and fix scripts](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-business-management/project-management/add-diagnostic-and-fix-script.md)\n\n"}}