Desktop User Guides > Professional > Interview scripting > Sample management > Sample management functions > ReturnSampleRec
 
ReturnSampleRec
This function is called by UNICOM Intelligence Interviewer - Server when an interview ends. Typically, this function places the sample record in the appropriate queue—for example, STOPPED or COMPLETED.
Syntax
Function ReturnSampleRec(SampleRec, SampleRecReturnCode)
Parts
SampleRec
Input parameter of type SampleRec.
SampleRecReturnCode
Input parameter of type SampleRecReturnCode.
Example 1
The function in this example checks whether the interview was completed or stopped and calls the Queues.MoveSampleRec Queues.MoveSampleRec method to move the sample record into the appropriate queue.
Function ReturnSampleRec(SampleRec, SampleRecReturnCode)
  If SampleRecReturnCode.Code = 1 Then
    Queues.MoveSampleRec "COMPLETED", SampleRec
    ReturnSampleRec = SUCCESS
  Else
    If SampleRecReturnCode.Code = 2 Then
      Queues.MoveSampleRec "STOPPED", SampleRec
      ReturnSampleRec = SUCCESS
    Else
      ReturnSampleRec = FAILURE ' Incorrect return code
    End If
  End If
End Function
Example 2
Before this function checks whether the interview was completed or stopped, it saves the respondent's serial number in the sample record in case the respondent needs to restart the interview. (UNICOM Intelligence Interviewer - Server needs the serial number to retrieve the correct case data record when it restarts an interview.) However, before moving the serial number into the sample record, the function checks that the sample record has a serial number field (because there would be an error if it tried to move the serial number into a field that does not exist) and if there is no serial number field, it logs a warning.
Function ReturnSampleRec(SampleRec, SampleRecReturnCode)
  On Error Resume Next
  Set SerialField = SampleRec.Fields("Serial")
  If (SerialField is Nothing) Then
    LogMessage = "ReturnSampleRec: Unable to save serial number"
    Log.LogThisEx 1001, LogMessage, LOGLEVEL_WARNING
  Else
    SampleRec.Fields("Serial").Value = _
    InterviewProperties.Item("Serial").Value
  End If
  If SampleRecReturnCode.Code = 1 Then
    Queues.MoveSampleRec "COMPLETED", SampleRec
    ReturnSampleRec = SUCCESS
  Else
    If SampleRecReturnCode.Code = 2 Then
      Queues.MoveSampleRec "STOPPED", SampleRec
      ReturnSampleRec = SUCCESS
    Else
      ReturnSampleRec = FAILURE ' Incorrect return code
    End If
  End If
End Function
For more information about Queues.MoveSampleRec, see Sample Management Object model.
See also
End of Interview Web Pages
Sample management functions