How to: Control Attachment Names Through Script

Overview

When capturing photos, videos or sounds, SurveyToGo will automatically generate the attachment name in order to make it unique. While usually there is no importance for the attachment name, sometimes there might be and there might also be a need for you to control the name the attachment is given.

For this purpose, you can utilize a special call back function that enables you to override the default name and assign your own name to the attachment.

Using the “OnGetAttachmentNameEx” call back function

To use the OnGetAttachmentName call back you need to write the following call back function in the “Advanced scripts” of your survey:

OnGetAttachmentNameEx – this call back allows you to alter the name of the attachment that will be generated. It is called each time an attachment is captured and just before the engine decides on the name. Here is an example of the call back function:

void OnGetAttachmentNameEx (inFilePath, inName, inQuestionAttachmentCount, inGlobalAttachmentCount, eAttachmentType inType)
{
var retVal = "PHOTO_Q_"+CurrQues+"_ATTACH_NUMBER_"+inQuestionAttachmentCount;
return retVal;
}

Parameter Description
inFilePath The full path of the local attachment file created on the device
inName The name of the attachment as given by SurveyToGo
inQuestionAttachmentCount The number of attachments in the current question (including this one)
inGlobalAttachmentCount The number of attachments in the interview
inType The type of the attachment

The above function will generate attachment names such as “PHOTO_Q_3_ATTACH_NUMBER_1.jpg″ utilizing the index of the current question and the number of attachments. You can use any survey logic function in this code.

Visit us at: http://www.dooblo.net

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.