handlers/kinetic_request_answer_create_v5/handler/init.rb
# The execute method takes no parameters and should leverage the instance
# variables setup and validated by the initialize method to generate a result
# xml string.
The execute method takes no parameters and should leverage the instance
variables setup and validated by the initialize method to generate a result
xml string.
The execute method takes no parameters and should leverage the instance variables setup and validated by the initialize method to generate a result xml string .
def execute()
	 base_entry = get_base_record(@parameters['SubmissionInstanceID'])
    question_entry = get_question(@parameters['TemplateName'],@parameters['QuestionName'], base_entry['SurveyInstanceID'])
	questionValue = @parameters['QuestionValue']
	if !questionValue.nil?
					fullAnswer = questionValue[0,3999]
					qlength = questionValue.bytesize
	else
					fullAnswer = questionValue
					qlength = 0
	end
    @field_values['QuestionInstanceID'] = question_entry['instanceId']
    @field_values['FullAnswer'] = fullAnswer
	puts("Question Length: \n#{qlength}") if @debug_logging_enabled
	if qlength > 4000
					@field_values['UnlimitedAnswer'] = questionValue
	end
	puts("Question Value: \n#{questionValue}") if @debug_logging_enabled
	puts("Full Answer: \n#{fullAnswer}") if @debug_logging_enabled
    if question_entry['Answer_MappingFieldID'] != nil
      field_id = question_entry['Answer_MappingFieldID']
      field_name = @@remedy_forms['KS_SRV_CustomerSurvey_base'].field_for(field_id.to_i).name
      base_entry.update_attributes!(field_name => @parameters['QuestionValue'])
    end
    puts(format_hash("Field Values:", @field_values)) if @debug_logging_enabled    
    entry = @@remedy_forms['KS_SRV_SurveyAnswer'].create_entry!(
      :field_values => @field_values
    )
    <<-RESULTS
    <results>
      <result name="Entry Id">#{escape(entry.id)}</result>
    </results>
    RESULTS
  end
def execute ( ) base_entry = get_base_record ( @parameters [ 'SubmissionInstanceID' ] ) question_entry = get_question ( @parameters [ 'TemplateName' ] , @parameters [ 'QuestionName' ] , base_entry [ 'SurveyInstanceID' ] ) questionValue = @parameters [ 'QuestionValue' ] if ! questionValue . nil? fullAnswer = questionValue [ 0 , 3999 ] qlength = questionValue . bytesize else fullAnswer = questionValue qlength = 0 end @field_values [ 'QuestionInstanceID' ] = question_entry [ 'instanceId' ] @field_values [ 'FullAnswer' ] = fullAnswer puts ( "Question Length: \n#{qlength}" ) if @debug_logging_enabled if qlength > 4000 @field_values [ 'UnlimitedAnswer' ] = questionValue end puts ( "Question Value: \n#{questionValue}" ) if @debug_logging_enabled puts ( "Full Answer: \n#{fullAnswer}" ) if @debug_logging_enabled if question_entry [ 'Answer_MappingFieldID' ] != nil field_id = question_entry [ 'Answer_MappingFieldID' ] field_name = @@remedy_forms [ 'KS_SRV_CustomerSurvey_base' ] . field_for ( field_id . to_i ) . name base_entry . update_attributes! ( field_name => @parameters [ 'QuestionValue' ] ) end puts ( format_hash ( "Field Values:" , @field_values ) ) if @debug_logging_enabled entry = @@remedy_forms [ 'KS_SRV_SurveyAnswer' ] . create_entry! ( :field_values => @field_values ) <<-RESULTS 
    <results>
      <result name="Entry Id"> #{ escape ( entry . id ) } </result>
    </results>
     RESULTS end
The execute method takes no parameters and should leverage the instance
variables setup and validated by the initialize method to generate a result
xml string.
The execute method takes no parameters and should leverage the instance variables setup and validated by the initialize method to generate a result xml string .
# Retrieve the Question Instance ID from the KS_SRV_SurveyQuestion form using # the Question Name and Template Name parameters. # Set the field_values hash with the Question IID. # Update the originating request's Attributes if the Answer value is mapped. We know # it's mapped if there is a value in the Answer_FieldMappingID variable. # Convert the Mapping Field ID to the Field Name # Update the Base Entry's mapped Attribute. # Create the entry using the ArsModels form setup the first time this # handler is executed.  The :field_values parameter takes a Hash of field # names to value mappings (which was built in the #initialize method).  The # :fields parameter is an optional Array of field values to return with the # entry.  By default (when the :fields parameter is omitted), all field # values are returned.  For large forms, the performance gained by # specifying a smaller subset of fields can be significant. # Return the results