@@ -218,7 +218,7 @@ def prov_copy
218218 )
219219
220220 if req . kind_of? ( ServiceTemplateProvisionRequest )
221- @dialog_replace_data = req . options [ :dialog ] . map { |key , val | { :name => key . split ( 'dialog_' ) . last , :value => val } } . to_json
221+ @dialog_replace_data = req . options [ :dialog ] . map { |key , val | { :name => key . split ( 'dialog_' ) . last , :value => parse_val ( key , val ) } } . to_json
222222 @new_dialog = true
223223 template = find_record_with_rbac ( ServiceTemplate , req . source_id )
224224 resource_action = template . resource_actions . find { |r | r . action . downcase == 'provision' && r . dialog_id }
@@ -338,6 +338,35 @@ def menu_section_id(parms = {})
338338
339339 private
340340
341+ def parse_val ( key , val )
342+ if val . kind_of? ( Integer ) # Handle integer values
343+ if key . include? ( "Array::" ) # Handle multi select with integers
344+ val = [ val ]
345+ else # Handle single select with integers
346+ return val
347+ end
348+ end
349+
350+ # TODO: Tag Control Field currently does not handle default values
351+ if val . include? ( "Classification::" ) # Handle tag control default values
352+ if val . include? ( "\u001F " ) # Array of tags
353+ val = val . split ( "\u001F " ) . map do |tag |
354+ Classification . find_by ( :id => tag . split ( '::' ) . second ) . id
355+ end
356+ else # Single tag
357+ val = Classification . find_by ( :id => val . split ( '::' ) . second ) . id
358+ end
359+ elsif key . include? ( "Array::" ) # Handle drop down with multi select default values
360+ if val . kind_of? ( String ) && val . include? ( "\u001F " ) # Check if string is an array of values
361+ val = val . split ( "\u001F " ) # Split the string into an array
362+ else
363+ val = [ val ] # Handle single string value
364+ end
365+ end
366+
367+ val # Handles all other conditions such as non-multi-select drop downs, text fields, etc.
368+ end
369+
341370 def replace_gtl
342371 render :update do |page |
343372 page << javascript_prologue
0 commit comments