function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bonny mankotiabonny mankotia 

Arithmetic expressions must use numeric arguments

I have a piece of code that show above error on

d.FolderId = UserInfo.getUserId();
         d.Name = 'Data2'; 
         String myContent = this.name+ '\n ' +this.pass+ '\n ' + this.age+ '\n ' +this.mail; 
         d.body += Blob.valueof(mycontent);
         d.ContentType = 'text/plain';
         d.Type = 'txt';
         upsert d;
         return null;
}

d.body += Blob.valueof(mycontent);(Show error in this line)
Pankaj_GanwaniPankaj_Ganwani
Remove the '+' operator since we cannot add two blob type variable values using '+' operator.

d.FolderId = UserInfo.getUserId();
         d.Name = 'Data2'; 
         String myContent = this.name+ '\n ' +this.pass+ '\n ' + this.age+ '\n ' +this.mail; 
         d.body = Blob.valueof(mycontent);
         d.ContentType = 'text/plain';
         d.Type = 'txt';
         upsert d;
         return null;
bonny mankotiabonny mankotia
Hi Pankaj but i have to append the content in the body of file
Pankaj_GanwaniPankaj_Ganwani
Okay, In this case, firstly you will have to convert the existing blob value of the record to string. Append 'myContent' variable value to this string and convert the consolidated string to blob and then assign it to 'd.body'.