VMware Aria

 View Only
  • 1.  upload File item in service broker : how to use it

    Posted Oct 08, 2023 10:54 PM

    Hello Everyone, 

    I have a use case where i want to add upload file item in custom form of a blueprint in service broker, to let the user attach a file that can be read by an approver to know the detail of the provisioning. how i can get the content of the file and decode it and attach it a PDF or a any format possible. any ideas ?

    Thank You.



  • 2.  RE: upload File item in service broker : how to use it

    Posted Oct 12, 2023 09:32 PM

     

    Hello Arar,
    you can find an approach to handle this with an input form of a workflow in the following post:

    https://communities.vmware.com/t5/VMware-Aria-Automation/FileUpload-Parameter-in-vRO-8-1/td-p/2287347

    Here a guide to add these input forms to the service broker catalog:

    https://docs.vmware.com/en/vRealize-Automation/8.11/Using-and-Managing-Service-Broker/GUID-416D6130-96AD-4912-9AD2-D52CE30CAA31.html

    Best regards
    Stefan



  • 3.  RE: upload File item in service broker : how to use it

    Posted Oct 12, 2023 10:41 PM
      |   view attached

       Thank you for your answer.

     

    Attachment(s)

    txt
    Base64.txt   2 KB 1 version


  • 4.  RE: upload File item in service broker : how to use it

    Posted Oct 13, 2023 06:43 AM

     

    Hello Arar,

    here an example to store the file in the temporary directory:

    1. Define in Inputs/Outputs an input variable, in our case in_file.

    StefanSchnell_0-1697178478004.png

    2. Add in the workflow a scriptable task and assign as input to this in_file. In this case I didn't rename the variable.

    StefanSchnell_1-1697178607796.png

    3. Following lines of code as an example to save any file in the temporary directory.

    StefanSchnell_2-1697178856797.png

    The function saveFileContent saves, with the method write, from the mime parameter, the file in the temporary directory. The lines above checks if a file with the same name exists and if the file exists it will be deleted.

    The function fileExists checks if a file with a specific name exists in the temporary directory and if it exists a message is displayed.

    // Begin----------------------------------------------------------------
    
    function saveFileContent(mime) {
      var file = new File(System.getTempDirectory() + "/" + mime.name);
      if (file.exists) {
        file.deleteFile();
      }
      mime.write(System.getTempDirectory(), null);
    }
    
    function fileExists(fileName) {
      var file = new File(System.getTempDirectory() + "/" + fileName);
      if (file.exists) {
        System.log("File " + fileName + " exists");
      }  
    }
    
    saveFileContent(in_file);
    fileExists(in_file.name);
    
    // End------------------------------------------------------------------

    4. Result

    StefanSchnell_3-1697179258752.png

    StefanSchnell_4-1697179295978.png

    Any file should be able to be saved this way.

    Best regards
    Stefan