How to Define Unstructured Data
SQL records are output without any body content.
You can write scripts to define unstructured data based on the values in your SQL result set.
- Navigate to Content Sources > SQL Content.
- Click
> Edit.
- On the Edit Database content page that appears select Item Definition >Unstructured Data Options.
- Leave the default setting or make a selection:
- Click Define by script.
-
Pick column (optional):
-
Click to select the metadata column.
-
Enter the following script into the scripting text box.
Copydim data as string = "TEST FILE:"dim meta1 as string = Host.GetStringValue("meta1")
dim meta2 as string = Host.GetStringValue("meta2")
data = data + " meta1 is:" + meta1
data = data + " meta2 is:" + meta2
dim extension as string = "txt"dim newFilePath as string = Host.GetTempFilePath(extension)
Host.SetFileExtension(extension)
File.WriteAllText(newFilePath,data)
return newFilePath -
- Compile: Click the Compile button.
Preserve Original file Content when writing Unstructured Data
- Navigate to Content Sources > WebService Content.
- Click
> Edit.
- On the Edit Database content page that appears select Item Definition >Unstructured Data Options > File(create Zip)
- Click Define by script:
-
Add the following code snippet to your script to ensure original file content is saved in the zip file:
Code snippetCopydim initialContent= HOST.GetFileContent()
if initialContent.length > 0
dim title= HOST.GetID()
Host.AddBlob(initialContent,name)
end if - Compile