Page 1 of 1

Form variable initialized in form method, but later empty

PostPosted: Fri Apr 25, 2014 4:33 pm
by deezzub
I have a form variable attachments initialized, which is filled with values in dc_newCustomToolbar. Later I want to access the object in another method, but then it is empty. I also tried an array atta.

Code: Select all
var attachments = { };
var atta = [ ];

function dc_newCustomToolbar( event, triggerForm, toolbarForm, createRecordOnTop ) {
   
   var attachment;
   
   attachment = plugins.file.showFileSaveDialog( );

   _super.dc_newCustomToolbar( event, triggerForm, toolbarForm, createRecordOnTop );

   if ( attachment ) {
      attachments[ id_nr ] = attachment;
      atta.push( [ id_nr, attachment ] );
      
      application.output( attachments[ id_nr ].getName( ) );
   }
}

function importAttachment( event, documentId ) {
      
   if ( attachments ) {
      for ( var idNo in attachments ) {
         if ( attachments.hasOwnProperty( idNo ) ) {

            application.output( idNo + ' ' + attachments[ idNo ] )
               
         }
      }

   }
}


If I call dc_newCustomToolbar again, then all before added content is available in the attachments object.

What I'm missing?