How to browse the files inside an instance folder using JavaScript? | Adobe Campaign Classic

adobe-campaign-javascript-browse-instance-files

This use-case that I am going to explain to you today is going to be extremely useful and will save a lot of your time during implementation.

As you know that Adobe supports both on-premise as well as on demand hosting.

On-premise :

The marketing instance is hosted on the customer’s infrastructure. You have access to the instance folder as it is hosted in your infrastructure.

On Demand:

In on-demand, Adobe hosts the marketing instance on its infrastructure. 

During implementation on an on-demand Adobe Campaign instance, you do not have access to the instance folder as it is hosted by Adobe. So, if you want to check the contents of the instance export folder, you have to raise a ticket to the Adobe support team. This will be a time-consuming task as the ticket goes through different phases and teams.

The support ticket gets created >> then it gets assigned >> then the support team reaches out to Adobe’s infrastructure team (there is separate SLA for support and infrastructure team) >>  Infrastructure team’s Jira also goes through the same assignment phase >> Infrastructure team then provides the data to support >> Support then provide the data to you.

That was a lot of time right?  🙂

For someone who values time will not prefer to go through this process as it will have an impact on your implementation timelines as well.

Now, that I have given you the context, let me give you the solution for this problem. Using this solution you can:

  1. Check all the files on the instance folder
  2. Check if the export activity has created the file on the instance folder.

All you need to implement this solution is 3 activities as shown below.

Start – JS activity – End

adobe-campaign-javascript-browse-instance-files-1

JavaScript Code:

Open the JavaScript activity and apply the below code to it.

  /*
  Author: Prajwal Shetty
  Version:2.3
  Date: 12/12/2018
  Purpose: To browse the files inside an instance folder
  */
  
  // Server folder to search
  var strFolderPath = "/usr/local/neolane/nl6/var/default/export/"
  // In the above path "default" is my local instance name
  
  // File pattern to be searched
  var strPattern = "*.csv"
  // We are looking for all files that have an extension as csv
  
  // Create a directory object to fetch its data
  var objDirectory = new File(strFolderPath)
  
  // Access all files inside the directory that match the search pattern
  var objFiles = objDirectory.list(strPattern)
  
  // Log the count of files
  logInfo("No. of files in the directory : " + objFiles.length)
  
  // Iterate and log its details
  for each(var fileObj in objFiles)
  {
    logInfo(fileObj.name + ": was last modified at " 
    + fileObj.lastModified)
  }

Workflow view:

adobe-campaign-javascript-browse-instance-files-2

Execute the workflow and you fill find the file details in the audit logs.

You can make changes to the JS to do much more. I know this because I have used it and it has helped me a lot my implementations. So wear your coding caps and transform the above code do more creative stuff.

To keep this post short, I will end with few tips on the search pattern.

You can use the below search patterns to match your requirement.

.” : all files.

“*.txt” : all text files.

“A.” : all files whose name start with A.

“Az.” : all files whose name start with A and ends with Z.

You can check my post How to get the complete list of whitelisted IPs?

Hope this helps.

error: Content is protected !!