How to apply a folder wise rule for assets creation?

I need to apply the rules folder-wise when uploading the documents. Is there any method similar to ‘assetContentUrl’ or any other way to get the folder name, so I can put it in the ‘if’ condition of ‘Assets Changed’?

The variables should be documented with the autocompletion. But for create you have the following base information:

var vars = new AssetScriptVars
        {
            // Tags and metadata are mutable and can be changed from the scripts, but not replaced.
            Command = new AssetCommandScriptVars
            {
                FileHash = create.FileHash,
                FileName = create.File.FileName,
                FileSlug = create.File.FileName.Slugify(),
                FileSize = create.File.FileSize,
                Metadata = create.Metadata,
                MimeType = create.File.MimeType,
                ParentId = create.ParentId,
                ParentPath = parentPath,
                Tags = create.Tags
            },
            Operation = "Create"
        };

so

command.parentId should give you the folder id.

or

command.parentPath[0].folderName`

Both are not returning anything. I tried capturing this information like below,
return {
“name”: {
“iv”: command.parentId
}
};

Sorry. I thought you are talking about asset scripts. For folder scripts there is nothing.

Edit: But you can try to download the asset with

getAsset(ctx.data.asset[0], function (asset) {

});

Thanks, Sebastian for the quick reply, but I am not looking for the download rather I need to know which folder the document is uploaded in the rule so that I can add a condition. Below is the link I am referring to,
https://docs.squidex.io/02-documentation/developer-guides/rule-formatting/script

I understand that. What I do not understand:

  1. Do you want to check the assets that are linked to a content item?
  2. Do you want to check the asset itself when it is uploaded to a folder?

In the first case you have to resolve the assets, because the content itself has only the IDs.

In the second case you should be able to use command.parentId directly.

It’s the second case, but can I use command.parentId in the rule?

Right now, you can only use the parentId, but unfortunately, it is only available for the Create Event. What would be your preferred way to work with folders?

Hey Sebastian, I just need to know which folder is being used to upload a new document. I am able to get it in the script, but not able to get it in the rule( assets script), could you please share code snippet.