Create transform job with Scripted Metric

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch 2.3

Describe the issue:
I’m following this document to create a transform job with scripted metric in Opensearch dashboard:

In Dev Tools, this script below can run successfully. However, putting this script into the scripted metrics box of the transform job doesn’t work. It showed format error and can’t save it. See the attached screenshots.

What is the proper syntax for Scripted Metic in the Index Transform job?

Configuration:
GET quality_intelligence_completed_counts/_search
{
“size”: 0,
“aggregations”: {
“qi_dipch”: {
“scripted_metric”: {
“init_script”: “state.responses = [‘defects’:0L,‘time’:0L]”,
“map_script”: “”"
def count = 0;
def walk = 0;

          if (doc['count_duration'].size() > 0) {
          	count = doc['count_duration'].value
          	}
          	
          if (doc['walk_time'].size() > 0) {
          	walk = doc['walk_time'].value
          	}	
          	
          state.responses.time = count + walk;

          if (doc['defective'].value == true) {
          	state.responses.defects = 1
          }
         """,
    "combine_script": "state.responses",     
    "reduce_script": """
        def counts = ['tdefects': 0L, 'ttime': 0L];
            for (responses in states) {
             counts.tdefects += responses['defects'];
              counts.ttime += responses['time'];
    		}
    	
    if (counts.ttime != 0) {
    		return Math.round(3600 * 100 * counts.tdefects / counts.ttime)/100.0
    	}	
    	else {
	        return 0;
	    }
    """
  }
}

}
}

Relevant Logs or Screenshots:

Only putting the scripted_metric part is ok, but the json editor doesn’t support multi-line strings, I’ve opened an issue about this [FEATURE] scripted_metrics json editor supports multi-line strings when defining transform · Issue #692 · opensearch-project/index-management-dashboards-plugin · GitHub.