cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass properties in CreateMedia action in MDK so that they are visible in SYCLO?

boolan79
Explorer
0 Kudos

Hello,

I am developing an MDK app using SYCLO framework in backend.

I need to create a business object and attach pictures to it.

The business object could successfully created with the ODataService.Create action.

Now, to be able to upload attachments, I changed the action type to ODataService.CreateMedia and added "Media" property for file contents:

{
    "_Type": "Action.Type.ODataService.CreateMedia",
    "Target": {
        "EntitySet" : "ZFaults",
        "Service" : "/SAPAssetManager/Services/AssetManager.service"
    },
    "Properties": {
        "ZZLongText": "#Control:FormCellNoteLongTextNote/#Value",
        "ZZFactor": "#Control:FormCellFactor/#Value",
        "ZZDamageCodeIndex": "#Property:ZZDamageCodeIndex",
        "ZZDamageCode":"#Control:FormDamageNr/#Value",
"ZZObjectType":"#Property:ZZObjectType",
        "ZZCause":"/SSAMCustom/Rules/WorkOrders/Operations/ZDamageGetCause.js",
"ZZVehicleNumber":"/SSAMCustom/Rules/WorkOrders/Operations/ZDamageGetVehicleNr.js",
        "ZZActivity": "/SSAMCustom/Rules/WorkOrders/Operations/ZDamageGetDamageActivityCode.js",
        "ZZActCodeGroup": "/SSAMCustom/Rules/WorkOrders/Operations/ZDamageGetDamageActivityCodeGroup.js"        
    },
 
    "Media": "#Control:AttachmentPhotoFormCell/#Value",
"ActionResult": {
"_Name": "CreateZFaultResult"
},
"OnSuccess": {
"Name": "/SSAMCustom/Actions/WorkOrders/Operations/ZMessageFaultSucces.action"
},
"OnFailure": {
        "Name": "/SSAMCustom/Actions/WorkOrders/Operations/ZMessageFaultFail.action"        
},        
    "ShowActivityIndicator": true
 
Also, I have set the "Media" flag for the entity in Syclo.
However, on backend side, in the oMDO handler class, only the method /MFND/IF_CORE_OMDO_HANDLER~CREATE_MEDIA is called.
And in this method I cannot see the properties which I set in MDK app.
The field REQUEST_DATA of the input parameter CREF_OMDO_DATA contains just the binary contents of the attachment. The attachment contents is correct and I can attach it to the business object if I fake the logic a little bit.
 
I had expected, that first the method /MFND/IF_CORE_OMDO_HANDLER~CREATE would be called to create the entry, and THEN /MFND/IF_CORE_OMDO_HANDLER~CREATE_MEDIA to attach the media.
According to standard SAP documentation for CreateMEdia action type:
boolan79_0-1709314950618.png
you can provide the properties and I would also like to use them in backend.
How can I pass these "Properties" from MDK to the method /MFND/IF_CORE_OMDO_HANDLER~CREATE_MEDIA
so that I can create business object and attach the images with just one request?
 
Or should I send 2 separate entities connected with navigation property?
Is there a tutorial showcasing this scenario?
 
Many thanks and best regards,
Chris
View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

I believe the create process for Media is the reverse where the media is first sent then any additional properties are sent in a second call.  You can check the OData specs on this to confirm.  Beyond that I am not familiar enough with the backend handling to help further.