This is an extension of my earlier question. When we export a SSJS library to DXL we get output which contains this:
<item name="$ServerJavaScriptLibrary" sign="true">
<rawitemdata type="1">
....ENCODED SSJS....
</rawitemdata>
</item>
I previously thought that the encoding scheme used here is Base64. But after trying unsuccessfuly to import SSJS library I think it is not. While searching I found that the type="1" refers to TYPE_COMPOSITE while type="14” refers to Base64 (please correct me if I am wrong on this one). I tried to use type="14" in my XML fil, put Base64 encoded code in rawitemdata tag and then tried to import the file. It created SSJS library in the database but its content was blank.
I found this link where it is importing a Theme by encoding it in Base64 but it prepends the encoded string by “YQAYAAAAAAA6AAAAAQAAAAAAAAAAAAAAYABMAAAAOgA6AAAAAAAAAAAA”. I tried to prepend it in my encoded SSJS code and then import it but still unsuccessful.
Which encoding scheme should be used so that I can import the SSJS code in my database?
A SSJS library is stored in richtext records. The encoded string before the data of the SSJS library is the base64 encoded header information these records.
Here you can find a working example how to encapsulate and import a SSJS library with DXL into a Database:
Quick-n-Dirty: Import SSJS libraries with DXL