AnsweredAssumed Answered

Display Success/Error Message After FileUpload in Share, how to do that?

Question asked by satheeshkumar on Feb 12, 2015

I have a scenario, like while uploading contents on a specific folder, I need to decide on which sub-folder should I upload this content based on the "prefix" that I extract from the file name, file name format would be like "". If the prefix is so and so I will move the uploaded file to the corresponding subfolder, say if prefix "BV" extracted from the file name "BV_dummyFile.txt", then I need to move it to the "Business Vertical" folder which is a sub folder of "Product Library" folder, so I have created script as shown below and applied it as a rule to the parent folder that is  "Product Library" folder.

function uploadDecider(){   
   var destFolder = "";
   var uploadedFileName = document.getName();
   var underscore_index = uploadedFileName.indexOf('_');
   if(underscore_index != -1){
      var prefix = uploadedFileName.substring(0, underscore_index);
      logger.log("Unable to get the prefix from the file name:'"+uploadedFileName+"' because file name doesn't contain '_'.");
   if("BANS".equals(prefix)) {
      destFolder = "Banner-Small";
   else if("BV".equals(prefix)) {
      destFolder = "Bookmark Vertical";
   var fileFolders = space.childFileFolders(false,true);
   for(var i=0; i<fileFolders.length; i++){
      var folderToCopy = fileFolders.getName();
         var parentNodeRef = space.childByNamePath(folderToCopy);
         var date = new Date();
            var code = Math.random().toString().slice(4,14);;
         var productCode = prefix+code;
         var childNodeRef = parentNodeRef.createFolder(productCode);
         var moveFile= document.move(childNodeRef);
         logger.log("Copied the content under :"+space.getName()+"/"+folderToCopy+"/"+productCode);         

Now what I want is whenever I upload a file, I should show the user a Message stating that the uploaded file is moved to the so and so folder/or the uploaded file removed since it doesn't have any prefix in the file filename. Currently I am logging in the server using
, but I want to show these information that I log, in the share UI to the user, can someone help.

Prefix Available scenario, the below message(sample message) needs to be shown
Copied the content under :Product Library/Bookmark Vertical/BV8911889422

Prefix not available scenario, the below message to be shown,
 Unable to get the prefix from the file name:'prefixmissingfilename.txt' because file name doesn't contain '_'.

I did an extensive search in forum, but unable to get any solution, below are the few links that are similar to it which I found during my search, but didn't get any proposed solution. any help would be greatly appreciated,