My code is:

public static string savedocs(String con, string name){// parameters i am getting from Js healper class. Here con is the JSON string contains list of object data.
        document doc=new document();
        doc.Body=con;// here i am getting error. illigal assignment string to blob.
            insert doc;

Please help me how to achieve this.


You need to convert String into blob to assign the value. You can't directly assign string here.

Blob body = blob.valueOf(con);
doc.Body= body ;
  • i used that, But the record is not saved in to the document object. – Arjun Reddy Feb 13 '18 at 10:28
  • @ArjunReddy Are you getting any exception? Did this method get called? – Tushar Sharma Feb 13 '18 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.