+ Start a Discussion
HuluSFAdminHuluSFAdmin 

Sending custom object data to SalesForce from Flex

I have custom object that looks like this in ActionScript. There is a corresponding custom object in SalesForce called LineItem.

 

 

public class LineItem { private var sfId:String; private var impressions:int; private var cpm:Number = 0.0; private var product:String; private var cost:Number; private var selected:Boolean; private var allocation:Number = 0.0; }

 

 What is an clean/elegant way of serializing this object from ActionScript to XML and then sending it to SalesForce.

 

Do I inherit from SObject and override the toXML() method? I looked at examples of developer.salesforce.com but none of them do anything like this.

 

Best Answer chosen by Admin (Salesforce Developers) 
arunkarunk

Hi,

 

Don know about eligance, but this is how i do it...

 

var o:Object = {}; o.impressions__C = impressions; o.cpm__C = cpm; o.product__C = product; o.cost__C = cost; o.selected__C = selected; o.allocation__C = allocation; o.type = "LineItem__C"; // o.type defines which object this is. var sObject:SObject = new SObject(o); apex.create( [sObject],new AsyncResponder(handleSaveResult,handleFault) );

Alternatively, you could create a function in your action script class called getSObject():SObject which would do the above.

 

Regards,

Arun