<p><code>folderPath</code> is not supported when relating an asset to an Entry but there is a workaround. In your generation script you can call the code below to get the <code>folderId</code> with the given path:</p>

<pre><code>$folderId = \craft\records\VolumeFolder::find()
-&gt;where(['path' =&gt; 'documents/pdfs/'])
-&gt;scalar();
</code></pre>

CC BY-SA 4.0
2018-10-16T17:48:45.790Z
Where is my "generation script"?
kmgdev
CC BY-SA 4.0
2018-10-17T13:31:07.433Z
@kgrote that is the script you created for the import json data format.
Dale Ramirez
CC BY-SA 4.0
2018-10-17T18:46:45.797Z
I didn't create a script. I just exported data in JSON format from ExpressionEngine and imported it to Sprout Import.
kmgdev
CC BY-SA 4.0
2018-10-18T21:32:44.680Z
Where in the docs does it talk about how to use an import script?
kmgdev
CC BY-SA 4.0
2018-10-16T06:44:20.280Z
2018-10-17T13:28:26.627Z
2018-10-17T13:28:26.627Z
Dale Ramirez
<p>I'm trying to import entries with an Asset inside a subfolder. Since I don't know what the new Craft subfolder ID will be for each Asset I tried to use the <code>folderPath</code> property from Craft's Asset element class:</p>

<pre><code>[
{
    "@model": "barrelstrength\\sproutimport\\importers\\elements\\Entry",
    "attributes": {
        "sectionId": 2,
        "typeId": 2,
        "authorId": 1,
        "slug": "my-sample-document",
        "postDate": "2017-11-09 13:06:00",
        "expiryDate": null,
        "enabled": true
    },
    "content": {
        "title": "My Sample Document",
        "fields": {
            "description": "&lt;p&gt;Nulla sit amet est. In hac habitasse platea dictumst. Pellentesque ut neque.&lt;/p&gt;"
        },
        "related": {
            "documentFile": {
                "@model": "barrelstrength\\sproutimport\\importers\\elements\\Asset",
                "params": {
                    "filename": ["my-sample-document.pdf"],
                    "volumeId": 9,
                    "folderPath": "documents/pdfs/"
                }
            }
        }
    }
}
]
</code></pre>

<p>However the import fails with this error:</p>

<blockquote>
  <p>[error][sprout-import] Setting unknown property: craft\elements\db\AssetQuery::folderPath</p>
</blockquote>

<p>I don't get an error when I use the <code>folderId</code> property. Can I only use properties that correspond with database columns? Is there any way to do this if I don't know the subfolder ID for every asset I'm importing?</p>

<ul>
<li>Craft 3.0.26.1 </li>
<li>Sprout Import 1.0.0-beta.14</li>
</ul>

<plugin-sproutimport>
Sprout Import Doesn't Recognize Asset folderPath Property
# Sprout Import Doesn't Recognize Asset folderPath Property

(Asked by: username_0 on 2018-10-05)

I'm trying to import entries with an Asset inside a subfolder. Since I don't know what the new Craft subfolder ID will be for each Asset I tried to use the folderPath property from Craft's Asset element class:
[
{
    "@model": "barrelstrength\\sproutimport\\importers\\elements\\Entry",
    "attributes": {
        "sectionId": 2,
        "typeId": 2,
        "authorId": 1,
        "slug": "my-sample-document",
        "postDate": "2017-11-09 13:06:00",
        "expiryDate": null,
        "enabled": true
    },
    "content": {
        "title": "My Sample Document",
        "fields": {
            "description": "Nulla sit amet est. In hac habitasse platea dictumst. Pellentesque ut neque."
        },
        "related": {
            "documentFile": {
                "@model": "barrelstrength\\sproutimport\\importers\\elements\\Asset",
                "params": {
                    "filename": ["my-sample-document.pdf"],
                    "volumeId": 9,
                    "folderPath": "documents/pdfs/"
                }
            }
        }
    }
}
]

However the import fails with this error:

[error][sprout-import] Setting unknown property: craft\elements\db\AssetQuery::folderPath

I don't get an error when I use the folderId property. Can I only use properties that correspond with database columns? Is there any way to do this if I don't know the subfolder ID for every asset I'm importing?

Craft 3.0.26.1 
Sprout Import 1.0.0-beta.14

**Tags:** plugin-sproutimport

---

## 1 answers

### Answer by username_1 on 2018-10-16. Score: 1

folderPath is not supported when relating an asset to an Entry but there is a workaround. In your generation script you can call the code below to get the folderId with the given path:
$folderId = \craft\records\VolumeFolder::find()
->where(['path' => 'documents/pdfs/'])
->scalar();

> **Comments:**
> **username_0**: Where is my "generation script"?  
> **username_1**: @kgrote that is the script you created for the import json data format.  
> **username_0**: I didn't create a script. I just exported data in JSON format from ExpressionEngine and imported it to Sprout Import.  
> **username_0**: Where in the docs does it talk about how to use an import script?  

---

