How to write the script for attached the file in workspace in popup window in sow workspace

reenak446674965
Tera Expert

I want  to write the  workspace client script ( pop up window ) for upload new version behavior it is just like the attachment functionalities as shown in screen shot in sow workspace . Could you please help me on this.

reenak446674965_0-1768565266266.png

 

11 REPLIES 11

Hi @vaishali231 

I added the alert in the code , only the first alert is working rest are not execute,

function onClick(g_form) {
    alert("test1");
      var modal = new nowModal({
        title: 'Import a Word File',
        size: 'md'
    });
alert("test2" +modal);
     modal.render(`
         <div style="padding:16px">
             <input type="file" id="ws_file" accept=".doc,.docx" />
             <br><br>
             <button class="btn btn-primary" onclick="uploadNewVersion()">Import</button>
         </div>
    `);

     window.uploadNewVersion = function () {
         var fileInput = document.getElementById('ws_file');
alert("test3 window function" +modal);
     if (!fileInput || !fileInput.files.length) {
             alert('Please select a file');
             return;
         }

         var file = fileInput.files[0];
alert("test4 window function" +modal);
         var attachmentHandler = new nowAttachmentHandler({
             tableName: g_form.getTableName(),
             tableSysId: g_form.getUniqueValue()
        });

        attachmentHandler.uploadAttachment(file).then(function () {
            alert("test5 window function" +modal);
             modal.close();
             g_form.refresh();
         });
     };
}

mohammedafi
Tera Contributor