Skip to Content
0
Jan 05, 2021 at 06:08 PM

CreateRelatedMedia error: Cannot read property 'content' of undefined.

352 Views Last edit Jan 05, 2021 at 09:51 PM 3 rev

Hello experts, I come to you with yet another question regarding the use of the CreateMedia action.

In my current scenario I need to create a new media object belonging to my MediaStreamSet entity (Media Type entity), and this newly created entity is dependent of an already existing Order object belonging to my OrderHeaderSet entity. I was looking at the documentation for the CreateRelatedMedia action and I thought this would be perfect for my scenario, since I need to create a new related entity and at the same time upload a media stream for it. The metadata for all my MDK elements seems to be exactly as shown in the documentation linked above but no matter what I try I keep getting this error:

I've got one parent entity (Order Header) and one dependent media type entity (Media Stream), you can check my service's metadata for these entities here: https://www.codepile.net/pile/aN2bj0N8

And one CreateRelatedMedia action that fetches the media content from a Form Cell Signature Capture Control (radio button is set to 'Current Page'):

{
    "IsOnlineRequest": false,
    "Media": "#Control:FormCellSignatureCapture0/#Value",
    "OnFailure": "/pmp_smart_pm/Actions/MyOrders/CreateMediaEntityImageFailureMessage.action",
    "OnSuccess": "/pmp_smart_pm/Actions/CloseModalPage_Complete.action",
    "ParentLink": {
        "Property": "OrderToMediaStreamNav",
        "Target": {
            "EntitySet": "OrderHeaderSet",
            "ReadLink": "{@odata.readLink}"
        }
    },
    "Properties": {
        "Filename": "/pmp_smart_pm/Rules/MyOrders/GetSignatureName.js"
    },
    "Target": {
        "EntitySet": "MediaStreamSet",
        "Service": "/pmp_smart_pm/Services/zpm_odata.service"
    },
    "_Type": "Action.Type.ODataService.CreateRelatedMedia"
}

The metadata for my form cell page containing the signature capture control can be seen here: https://www.codepile.net/pile/ZEGkmPEq

To be on the safe side I debugged all my controls and rules involved in this process and the binary content from the Form Cell controls is being captured successfully.

Attachments

create-media.png (20.2 kB)