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
myztakenmyztaken 

Calling an ApexWS from Flex including custom objects as parameters

Hi there..

 

I'm trying to  call an Apex WS from my Flex application. When I use this way... Assuming that session is an active connection with SF using the Connection class from the flextoolkit...

 

 

public function loadPowerChart(oppId:String, callback:AsyncResponder):void { var powerChart:PowerChart; loadPowerChartCallback.context.clientCallback = callback; var executeParams:Object = { className: "OptimizerWS", methodName: "loadPowerChart", args: [new Parameter("oppId", "0068000000MsLwM")], callback: loadPowerChartCallback, nameSpace: "optimizer" }; session.execute(executeParams); }

Everything works fine, and im getting my Custom object back as I expected...

 

But when I send the object from flex to Apex I cant find a way to make it so...

 

Im trying the following:

 

 

public function savePowerChart(oppId:String, callback:AsyncResponder, powerChart:PowerChart):void { savePowerChartCallback.context.clientCallback = callback; var sfPowerChart:SObject = powerChart.toSObject(); trace(sfPowerChart.toDebugString()); var executeParams:Object = { className: "OptimizerWS", methodName: "loadPowerChart", args: [new Parameter("powerChart",sfPowerChart)], callback: savePowerChartCallback, nameSpace: "optimizer" }; session.execute(executeParams); }

 

 And the toSObject on my PowerChart flex has the following code inside...

 

 

public function toSObject():SObject{ var sfObject:SObject = new SObject('optimizer__SO_Power_Chart__c'); sfObject.optimizer__Optimizer_ID__c = this.id; return sfObject; }

 

 The Trace from the toDebugString() on the SObject prints the following...

 

 

SObject type:optimizer__SO_Power_Chart__c optimizer__Optimizer_ID__c:23D0FB27-C4F9-B5D3-163F-FB7D44FCD302

 

And the error displayed on my callback is the following...

 

 

Unexpected element {http://soap.sforce.com/schemas/class/optimizer/OptimizerWS}type during simple type deserialization

 

 And my saveProbabilityChart WS method is the following...

 

 

webservice static List<String> savePowerChart(SO_Power_Chart__c powerChart){ System.debug('Entering loadPowerChart: Chart=>'+powerChart);//+' oppId=>'+oppId); List<String> errors = new List<String>(); System.debug(powerChart); return errors; }

 

... I don't really know the correct way to do it... But I know that someone in here could help me arround...

 

Thanks in advance...:manhappy:

 

~ foe