handlers/kinetic_request_submission_format_answers_html_v5/handler/init.rb
# Builds and returns the results of interpreting the desired template String
# within the current context (IE exposing the @answers variable).
#
# This is a required method that is automatically called by the Kinetic Task
# Engine.
#
# ==== Returns
# An HTML formatted String representing the return variable results.
Builds and returns the results of interpreting the desired template String
within the current context .

This is a required method that is automatically called by the Kinetic Task
Engine.

Returns
An HTML formatted String representing the return variable results.
Builds and returns the results of interpreting the desired template String within the current context . This is a required method that is automatically called by the Kinetic Task Engine . Returns An HTML formatted String representing the return variable results .
def execute()
	if (@parameters['template'] == "Yes") 
		result= "<h2>" +@base_entry['Survey_Template_Name'] +"</h2>"
	else
		result= ""
	end
	result << "\n" << @parameters['h_table_structure']
	result << "\n" << @parameters['q_table_wrapper_open']
	result << "\n" << @parameters['q_tbody_wrapper_open']
	if (@parameters['template'] == "Yes") 
		textresult = "Answers for " +@base_entry['Survey_Template_Name'] +":\n"
	else
		textresult = "Answers:\n"
	end
	@question_answer_entries.each do |entry|
		label = entry['QuestionLabel'] || entry['Question']
		@answer = entry['FullAnswer']
		if !@answer.nil?
			 answerQual = %|'700001850' = "#{@parameters['csrvId']}" AND '700001890' = "#{entry['QuestioninstanceId']}"|
			 answer_entry = @@remedy_forms['KS_SRV_SurveyAnswer'].find_entries(
			  :single,
			  :conditions => [answerQual],
			  :fields     => :all
			)
			if !answer_entry['Unlimited Answer Id'].nil?
				unlimited_answer_entry = @@remedy_forms['KS_SRV_SurveyAnswerUnlimited'].find_entries(
				  :single,
				  :conditions => [answerQual],
				  :fields     => :all
				)
				if !unlimited_answer_entry.nil?
					@answer = unlimited_answer_entry['UnlimitedlAnswer']
				end
			end
		end
		result << "\n" << @parameters['q_tr_wrapper_open']
		result << "\n" << @parameters['q_td_qlabel_wrapper_open']
		result << "\n" << escape_html(label) << ""
		result << "\n" << @parameters['q_td_qlabel_wrapper_close']
		result << "\n" << @parameters['q_td_qanswer_wrapper_open']
		result << "\n" << escape_html(@answer)
		result << "\n" << @parameters['q_td_qanswer_wrapper_close']
		result << "\n" << @parameters['q_tr_wrapper_close']
		textresult << "#{label}: #{@answer}\n"
	end
	result << "\n" << @parameters['q_tbody_wrapper_close']
	result << "\n" << @parameters['q_table_wrapper_close']
	link = ""
	if (@parameters['link'] == "Yes")
		@linkQuery = %|'Attribute_Parent_InstanceId' = "#{@base_entry['SurveyInstanceID']}" AND 'Attribute Type Name' = "Review JSP"|
		@attribute_entry = @@remedy_forms['KS_ATT_AttributeInstance'].find_entries(
		  :first,
		  :conditions => [@linkQuery],
		  :fields     => ['Character_Value']
		)
		link = @parameters['webServer']+"ReviewRequestPage?csrv="+@parameters['csrvId']+"&pageInstanceID="+@base_entry['PageInstanceId']
		if !@attribute_entry.nil?
			link = link + "&reviewPage=" + 	@attribute_entry['Character_Value']
		end
	result << "\n<br>" << link
	textresult << "\n" << link
	end
	puts("Results: \n#{result}") if @debug_logging_enabled
	puts("Text Results: \n#{textresult}") if @debug_logging_enabled
    <<-RESULTS
    <results>
      <result name="result">#{escape(result)}</result>
	  <result name="textresult">#{escape(textresult)}</result>
    </results>
    RESULTS
  end
def execute ( ) if ( @parameters [ 'template' ] == "Yes" ) result = "<h2>" + @base_entry [ 'Survey_Template_Name' ] + "</h2>" else result = "" end result << "\n" << @parameters [ 'h_table_structure' ] result << "\n" << @parameters [ 'q_table_wrapper_open' ] result << "\n" << @parameters [ 'q_tbody_wrapper_open' ] if ( @parameters [ 'template' ] == "Yes" ) textresult = "Answers for " + @base_entry [ 'Survey_Template_Name' ] + ":\n" else textresult = "Answers:\n" end @question_answer_entries . each do | entry | label = entry [ 'QuestionLabel' ] || entry [ 'Question' ] @answer = entry [ 'FullAnswer' ] if ! @answer . nil? answerQual = %|'700001850' = "#{@parameters['csrvId']}" AND '700001890' = "#{entry['QuestioninstanceId']}"| answer_entry = @@remedy_forms [ 'KS_SRV_SurveyAnswer' ] . find_entries ( :single , :conditions => [ answerQual ] , :fields => :all ) if ! answer_entry [ 'Unlimited Answer Id' ] . nil? unlimited_answer_entry = @@remedy_forms [ 'KS_SRV_SurveyAnswerUnlimited' ] . find_entries ( :single , :conditions => [ answerQual ] , :fields => :all ) if ! unlimited_answer_entry . nil? @answer = unlimited_answer_entry [ 'UnlimitedlAnswer' ] end end end result << "\n" << @parameters [ 'q_tr_wrapper_open' ] result << "\n" << @parameters [ 'q_td_qlabel_wrapper_open' ] result << "\n" << escape_html ( label ) << "" result << "\n" << @parameters [ 'q_td_qlabel_wrapper_close' ] result << "\n" << @parameters [ 'q_td_qanswer_wrapper_open' ] result << "\n" << escape_html ( @answer ) result << "\n" << @parameters [ 'q_td_qanswer_wrapper_close' ] result << "\n" << @parameters [ 'q_tr_wrapper_close' ] textresult << "#{label}: #{@answer}\n" end result << "\n" << @parameters [ 'q_tbody_wrapper_close' ] result << "\n" << @parameters [ 'q_table_wrapper_close' ] link = "" if ( @parameters [ 'link' ] == "Yes" ) @linkQuery = %|'Attribute_Parent_InstanceId' = "#{@base_entry['SurveyInstanceID']}" AND 'Attribute Type Name' = "Review JSP"| @attribute_entry = @@remedy_forms [ 'KS_ATT_AttributeInstance' ] . find_entries ( :first , :conditions => [ @linkQuery ] , :fields => [ 'Character_Value' ] ) link = @parameters [ 'webServer' ] + "ReviewRequestPage?csrv=" + @parameters [ 'csrvId' ] + "&pageInstanceID=" + @base_entry [ 'PageInstanceId' ] if ! @attribute_entry . nil? link = link + "&reviewPage=" + @attribute_entry [ 'Character_Value' ] end result << "\n<br>" << link textresult << "\n" << link end puts ( "Results: \n#{result}" ) if @debug_logging_enabled puts ( "Text Results: \n#{textresult}" ) if @debug_logging_enabled <<-RESULTS 
    <results>
      <result name="result"> #{ escape ( result ) } </result>
	  <result name="textresult"> #{ escape ( textresult ) } </result>
    </results>
     RESULTS end
Builds and returns the results of interpreting the desired template String
within the current context (IE exposing the @answers variable).
Builds and returns the results of interpreting the desired template String within the current context ( IE exposing the @answers variable ) .
# Get the question label.  Note that if the question label is nil we will use # the question name which cannot be nil. # Build the table row html code for the current question answer entry. #result << "\n" << label << ":" # Build the plain text line for the current question answer entry. #search for all the questions # Return the results String