Search code examples
mobilemovilizer

Movilizer - changing name of captured image


In my scenario I'm using the image capture screen for taking photos of specific machines.

In the replies the name of the images is 1427726930.jpg

Can this name be changed I'd like to have a prefix like: UIDxxxxxxTSxxxxxx.jpg


Solution

  • It is possible to override the auto generated name in the image capture screen, by calling setAnswerValue on the Answer that contains the image after capturing. For your scenario this can look as follows:

            <question key="#1" type="10" title="">
    
                <answer key="#1_1" nextQuestionKey="END"/>
    
                <onLeaveOkPersistAssignment>
                    init = getAnswerValue($answer:'#1_1');
                    renamed = conCat('ID', getUserId(), '-', init);
                    setAnswerValue($answer:'#1_1', renamed);
                    newName = getAnswerValue($answer:'#1_1');
                </onLeaveOkPersistAssignment>
    
            </question>
    

    calling getAnswerValue returns the auto generated name which is a numeric timestamp followed by the file extension. This is practically the part of your pattern after the TS. So all you have to do is to retrieve the participant ID and to concatenate everything in the right order.