1

I'm investigating the SSJS activities. I'm not a JavaScript programmer but I'm trying to learn. Now I have managed to create Date Extension, a Create a folder path. Now I would like to be able to write (in the same script or a new one) a script that takes a Date Extension and move it to a folder. How do I implement this?

At the moment I'm trying to test this code, but it does not work.

<script runat=server>

Platform.Load("core","1");

var FolderScript= Folder.Retrieve({Property:"Name",SimpleOperator:"equals",Value:"Folder Script"});
var FolderScriptID = FolderScript[0].ID;

var DEscript= DataExtension.Init("ScriptDE20");
DEscript.setFolderId(FolderScriptID);

</script>
1

You have to use DataExtension SSJS function for moving DataExtension one folder to another and pass the destination folder id.

<script runat=server>

Platform.Load("core","1");

var updateDE = DataExtension.Init('demoDE'); //DE ExternalKey 
var newFolder = {
    CategoryID : "95232" // FolderID
};
var myDE = updateDE.Update(newFolder);
Write(myDE);

</script>

Result: OK

  • I have problem in the line : var myDE = updateDE.Update(newField); Maybe the right way is : var myDE = updateDE.Update(newFolder); Also in this case doesn't work ! – R.Pruner Sep 7 '16 at 10:55
  • It should work, you just need to change the DE ExternalKey and FolderID in above code. – Palash Rai Sep 7 '16 at 11:06
  • Sorry, but I don't understand the code. Why did you insert "newField" in the Update(...) ? and why did you creare an object " newFolder" ? I think that in this way I am not able to pass the destination folder id. – R.Pruner Sep 7 '16 at 13:02
  • I think it's a mistake. In fact, I am changing the names I was able to do this thing. – R.Pruner Sep 7 '16 at 13:11
  • I have updated my code. – Palash Rai Sep 7 '16 at 13:15
1

This the right code to achieve my requirement:

<script runat=server>

Platform.Load("core","1");

var FolderScript= Folder.Retrieve({Property:"Name",SimpleOperator:"equals",Value:"Folder Script"});
var FolderScriptID = FolderScript[0].ID;

var updateDE = DataExtension.Init('ScriptDE20'); //DE ExternalKey 

var newField = {
        "CategoryID" : FolderScriptID // FolderID
    };

var myDE = updateDE.Update(newField);
Write(myDE);

</script>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.