+ Start a Discussion
anup-prakashanup-prakash 

Not Serializable: System.XmlStreamWriter

global class BatchJSToWorkdayOfferSync implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts{

	global String xmlStringxmlRes;
	global System.XmlStreamWriter xmlW;
		
   	global Database.QueryLocator start(Database.BatchableContext BC){
      	xmlW= new System.XmlStreamWriter();
      	xmlW.writeStartDocument('utf-8','1.0');
        String query = ' My QUERY';
      
      return Database.getQueryLocator(query);
      }

global void execute(Database.BatchableContext BC, List<myObject> myObjectList){

}

global void finish(Database.BatchableContext BC){
		
		xmlW.writeEndDocument(); //Close XML document
	
		xmlStringxmlRes = xmlW.getXmlString();
		System.debug('The XML :'+xmlW.getXmlString());
		xmlW.close();
		//sendEmail(xmlStringxmlRes);
	}

and I am receiving Not Serializable: System.XmlStreamWriter
Vivek DVivek D
Try declaring the variables as Transient
It will work
anup-prakashanup-prakash
Need to have a property. Have you tried it? In a Batch?