Expand my Community achievements bar.

Convert document back to string

Avatar

Level 4

Dear all,

I just find out that if I assign a string into a document variable, I will be able to see the string in the document content.

But if I assign this document back to a string variable, I won't get the original string back.

Would like to know what should I do to get it back?

Regards

Bill

2 Replies

Avatar

Level 10

document is a complex type while the string is a simple data type.

While coercing document to string, the document's content will be converted into base64 encoded string and will be assigned to the string variable.

You can try any of these options:

Option 1: You could write a custom component to decode the base64 string

Option 2: save the document content to a temporary file and read the file content as string (Using readString activity).

Hope that may help you.

Nith

Avatar

Level 4

Hi Nith,

Thanks for the reply.

That's mean that is not directly supported, I should:

1) Write java in script object

2) Write a user component

3) Workaround by using read/write files service

Regards

Bill