Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Problem with dataservices query.

Avatar

Level 2

Hello,

We're getting a Type Coercion failed error (TypeError: Error #1034: Type Coercion failed: cannot convert _ProductMasterSpecificationsEntityMetadata@18599b01 to mx.data.IManaged.) when we call a second time a getByProduct but only in one case because everything else seems to work.

Here's a sample code, the error occur when we click a second time on the button:

protected function button1_clickHandler(event:MouseEvent):void

{

     productMasterSpecificationDetailsService.getByProductMasterSpecificationDetailsUniqueID(_spec);

}

<fx:Declarations>

     <s:CallResponder id="getByProductMasterSpecificationDetailsUniqueIDResult"/>

     <services:ProductMasterSpecificationDetailsService

          id="productMasterSpecificationDetailsService"

          fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"

          result="productMasterSpecificationDetailsService_resultHandler(event)"/>

</fx:Declarations>

<s:Button click="button1_clickHandler(event)" />

Artour.

LordAlex Works Inc.

5 Replies

Avatar

Level 2

To be more precise the error occurs when lcds try to convert mysql data to flex data model.

And it happens when calculateUpdateDateIsValid is called from _ProductMasterSpecificationsEntityMetadata

Here's the full error:

TypeError: Error #1034: Type Coercion failed: cannot convert _ProductMasterSpecificationsEntityMetadata@1856ba61 to mx.data.IManaged.
     at mx.data::DataList/getItemIndex()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataList.as:376]
     at mx.collections::ListCollectionView/getItemIndex()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:678]
     at mx.collections::AsyncListView/getItemIndex()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\AsyncListView.as:732]
     at spark.components::DataGroup/http://www.adobe.com/2006/flex/mx/internal::dataProvider_collectionChangeHandler()[E:\dev\4.x\frameworks\projects\spark\src\spark\components\DataGroup.as:1746]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at mx.utils::OnDemandEventDispatcher/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\utils\OnDemandEventDispatcher.as:71]
     at mx.collections::AsyncListView/handleCollectionChangeEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\AsyncListView.as:210]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1024]
     at mx.collections::ListCollectionView/handlePropertyChangeEvents()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
     at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1300]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at mx.data::ConcreteDataService/dispatchCollectionEvent()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:6801]
     at mx.data::ConcreteDataService/dispatchLeafCollectionEvent()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:7559]
     at mx.data::ConcreteDataService/itemUpdateHandler()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:7554]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at Function/<anonymous>()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:1083]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at _ProductMasterSpecificationsEntityMetadata/set http://www.adobe.com/2008/flex/model/internal::_createDateIsValid_der()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/models/_ProductMasterSpecificationsEntityMetadata.as:992]
     at _ProductMasterSpecificationsEntityMetadata/http://www.adobe.com/2008/flex/model/internal::calculateCreateDateIsValid()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/models/_ProductMasterSpecificationsEntityMetadata.as:1010]
     at _ProductMasterSpecificationsEntityMetadata/get createDateIsValid()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/models/_ProductMasterSpecificationsEntityMetadata.as:1001]
     at mx.data.utils::Managed$/internalCompare()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:648]
     at mx.data.utils::Managed$/internalCompare()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:649]
     at mx.data.utils::Managed$/arrayCompare()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:696]
     at mx.data.utils::Managed$/internalCompare()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:608]
     at mx.data.utils::Managed$/http://www.adobe.com/2006/flex/mx/internal::compare()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\utils\Managed.as:522]
     at mx.data::ConcreteDataService/http://www.adobe.com/2006/flex/mx/internal::getDataListWithFillParams()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:3751]
     at mx.data::ConcreteDataService/internalFill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:7178]
     at Function/<anonymous>()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1317]
     at mx.data::ConcreteDataService/fill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1336]
     at mx.data::DataManager/fill()[C:\depot\DataServices\trunk\frameworks\projects\data\src\mx\data\DataManager.as:1560]
     at com.adobe.livecyclewizard.services::ProductMasterSpecificationDetailsService/getByProductMasterSpecificationDetailsUniqueID()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/services/ProductMasterSpecificationDetailsService.as:24]
     at com.adobe.livecyclewizard.components::productComp/button1_clickHandler()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/components/productComp.mxml:40]
     at com.adobe.livecyclewizard.components::productComp/___productComp_Button1_click()[/Users/artour/Documents/Clients/Adobe/newLiveCycle/Adobe-LiveCycle/src/com/adobe/livecyclewizard/components/productComp.mxml:113]

Avatar

Level 1

Hello Artour - I'm running into the same thing.. were you able to resolve? - Nathan

Avatar

Level 2

Hi Nathan,

we followed this video: http://www.vimeo.com/6612999

at the 8th minute when he adds a new property and makes the relationship options bi-directional that seems to make it work for us.

Artour

LordAlex Works Inc.

Avatar

Level 1

Hi Artour,

Thank you for the lead. As soon as I saw "bi-directional" I knew you solved the mystery thx!

Sent from my iPhone