cancel
Showing results for 
Search instead for 
Did you mean: 

MDK Odata Update Action Not working as expected

0 Kudos

Hi,

I am using a following action to UpdateEntity action the one property of my entity Set and then overriding the entity set from a rules. But when the action executed for the first time it's worked perfectly but when I performing same action on the same entity the action returning success but the entity set is not getting updated.

{ "_Type": "Action.Type.ODataService.UpdateEntity", "Target": { "Service": "/SampleMDKApp/Services/com_test_mdk_app_service.service", "EntitySet": "TestGRDetails", "ReadLink": "{@odata.readLink}" }, "Properties": { "Status": "0" }}

UpdateStatus.js


export default function UpdateStatus(clientAPI) {
  
let selectedItem = clientAPI.getPageProxy().getActionBinding();
let name = selectedItem["Name"] let status = selectedItem["Status"]
let updatedStatus = (status === "1") ? "0" : "1"
let updatePromise = clientAPI.executeAction({ "Name": "/SampleMDKApp/Actions/Application/UpdateGRStatusAction.action", "Properties":{ "Status": updatedStatus
} });
updatePromise.then((result)=>{ alert(`${name} Status Updated.`); }).catch((err) => { alert(`UpdateStatus Clicked `); });
return updatePromise;}
View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert

You may want to also override the ReadLink to ensure that the update action is always targeting the correct entity.

let updatePromise = clientAPI.executeAction({
    "Name": "/SampleMDKApp/Actions/Application/UpdateGRStatusAction.action",
    "Properties": {
        "Target": {
            "ReadLink": selectedItem['@odata.readLink']
        },
        "Properties": {
            "Status": updatedStatus
        }
    }
});

Thanks for the answer it's worked.