8

I just started a new job with a company and there tracking is a mess. All of the files are just at the root "My Tracking" and there are 1000s of sends. I want to move all sends with the word "Ticket" somewhere in the name to a new folder. I saw that someone solved this using Server Side JavaScript, but I don't seem to have JS enabled in my account. (It's not where he said it would be) So I'm wondering if I can move these sends with a Query activity and Automation Studio? It's very hard to find good Query documentation or examples from Salesforce, otherwise, I would just get cracking and see if I could figure it out. Thanks for your help!

Here is the other thread for reference Automated way to move emails between folders?

This code works to move one email to another folder

<script runat="server">
Platform.Load("core","1");

var sourceFolderID = 31249; //You can find the CategoryID of a folder by hovering over the folder in your browser and looking at the path in the lower left of your browser
//the CategoryID used above, 31249, is the "My Emails" folder in the root
var emailName = "Stan Test Email"; 
var destFolder = 119461; //Enter your destination folder CategoryID here

         var folderFilter = {Property : "CategoryID", SimpleOperator : "equals", Value : sourceFolderID};
         var nameFilter = {Property : 'Name', SimpleOperator : 'equals', Value : emailName};
         var combinedFilter = {LeftOperand : folderFilter, LogicalOperator : 'AND', RightOperand : nameFilter};

         var results = Email.Retrieve(combinedFilter);

         for (var i=0; i < results.length ; ++i) {

             var emailObj = Email.Init(results[i].CustomerKey);
             emailObj.Update({ "CategoryID" : destFolder});
         }

</script>

I thought that by simply changing Email.Init and Email.Retrieve to Send.Init and Send.Retrieve I could get it working, but no luck. I think it's because there is no Update method on the Send Object

6
  • 1
    You should be able to get SSJS scripting interaction enabled on your account (no cost) by talking to your rep or global support (As long as you have Automation Studio on your account). For some reason they do not enable this feature by default. Jul 12 '17 at 12:49
  • 1
    please make sure to update your question with what you find out - in case anyone else has this issue. Jul 12 '17 at 15:36
  • Ok I will. But I still can't get it working. I have SSJS installed but not even a basic script will run. And the docs suck. I'm not sure what I'm doing wrong. I am just trying to update an email name in the "My Tracking" folder and even this little thing won't work. I don't know where to get the CustomerKey. I got the number here by hovering over the email and looking at the address in the browser. var emailObj = Email.Init(31253); emailObj.Update({ "Name" : "mexico_may17_2" });
    – garek007
    Jul 12 '17 at 17:24
  • CustomerKey is the ExternalKey. also make sure you use the open/close script tags. A good place to practice and get error logs is by using a LP or microsite to build the code on - provides you somewhat detailed errors, not just 'error'. Jul 12 '17 at 17:28
  • sorry I do have the open close script tags. I don't see an external key on sent emails or even unsent emails. I do see an ID though
    – garek007
    Jul 12 '17 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.