handlers/kinetic_request_submission_build_attachment_url_v2/handler/init.rb
# Builds a download URL for the attachment file that was the answer to the specified
# question on the current submission.
#
# This is a required method that is automatically called by the Kinetic Task
# Engine.
#
# ==== Returns
# An XML formatted String representing the return variable results.
Builds a download URL for the attachment file that was the answer to the specified
question on the current submission.

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

Returns
An XML formatted String representing the return variable results.
Builds a download URL for the attachment file that was the answer to the specified question on the current submission . This is a required method that is automatically called by the Kinetic Task Engine . Returns An XML formatted String representing the return variable results .
def execute()
    survey_question_entry = @@remedy_forms['KS_SRV_SurveyQuestion'].find_entries(
      :single,
      :fields     => ['instanceId'],
      :conditions => [%|'Editor Label' = "#{@parameters['question_menu_label']}" AND | <<
          %|'SurveyInstanceID' = "#{@parameters['survey_template_instance_id']}"|]
    )
    if survey_question_entry.nil?
      raise "No question was found with the specified label \"#{@parameters['question_menu_label']}\""
    end
    question_answer_entry = @@remedy_forms['KS_SRV_QuestionAnswerJoin'].find_entries(
      :single,
      :fields     => ['FullAnswer'],
      :conditions => [%|'QuestioninstanceId' = "#{survey_question_entry['instanceId']}" AND | <<
          %|'CustomerSurveyInstanceID' = "#{@parameters['customer_survey_instance_id']}"|]
    )
    if question_answer_entry.nil?
      file_name = ""
      url = ""
    else
      file_name = question_answer_entry['FullAnswer']
      url = %|SimpleDataRequest| <<
        %|?requestName=getFile| <<
        %|&dataRequestId=existingAttachment| <<
        %|&sessionId=#{encode_url_parameter(@parameters['customer_survey_instance_id'])}| <<
        %|&questionId=#{encode_url_parameter(survey_question_entry['instanceId'])}| <<
        %|&fileName=#{encode_url_parameter(question_answer_entry['FullAnswer'])}| <<
        %|&noCache=#{encode_url_parameter(Time.now.to_i)}|
    end    
    <<-RESULTS
    <results>
      <result name="URL">#{escape(url)}</result>
      <result name="File Name">#{escape(file_name)}</result>
    </results>
    RESULTS
  end
def execute ( ) survey_question_entry = @@remedy_forms [ 'KS_SRV_SurveyQuestion' ] . find_entries ( :single , :fields => [ 'instanceId' ] , :conditions => [ %|'Editor Label' = "#{@parameters['question_menu_label']}" AND | << %|'SurveyInstanceID' = "#{@parameters['survey_template_instance_id']}"| ] ) if survey_question_entry . nil? raise "No question was found with the specified label \"#{@parameters['question_menu_label']}\"" end question_answer_entry = @@remedy_forms [ 'KS_SRV_QuestionAnswerJoin' ] . find_entries ( :single , :fields => [ 'FullAnswer' ] , :conditions => [ %|'QuestioninstanceId' = "#{survey_question_entry['instanceId']}" AND | << %|'CustomerSurveyInstanceID' = "#{@parameters['customer_survey_instance_id']}"| ] ) if question_answer_entry . nil? file_name = "" url = "" else file_name = question_answer_entry [ 'FullAnswer' ] url = %|SimpleDataRequest| << %|?requestName=getFile| << %|&dataRequestId=existingAttachment| << %|&sessionId=#{encode_url_parameter(@parameters['customer_survey_instance_id'])}| << %|&questionId=#{encode_url_parameter(survey_question_entry['instanceId'])}| << %|&fileName=#{encode_url_parameter(question_answer_entry['FullAnswer'])}| << %|&noCache=#{encode_url_parameter(Time.now.to_i)}| end <<-RESULTS 
    <results>
      <result name="URL"> #{ escape ( url ) } </result>
      <result name="File Name"> #{ escape ( file_name ) } </result>
    </results>
     RESULTS end
Builds a download URL for the attachment file that was the answer to the specified
question on the current submission.
Builds a download URL for the attachment file that was the answer to the specified question on the current submission .
# Retrieve the KS_SRV_SurveyQuestion record for the given question menu label # and the current survey template instance id. # Retrieve the KS_SRV_QuestionAnswerJoin record for the given question and the  # current submission. # If there is no record on KS_SRV_QuestionAnswerJoin, the question was not answered # and we will return an empty string.  Otherwise, we will build the HTML link # from all of the data that was input and retrieved by this handler. # Return the results String