Skip to Content
0
Mar 02, 2022 at 07:22 AM

How to update entities over loop items of a read result in MDK?

216 Views Last edit Mar 02, 2022 at 07:41 AM 3 rev

I’m trying to do an update entity action based on a loop over a read result. However, the update action can’t get the bindings I set in the rule. The log shows that @data.readlink is null so that the update action can't be executed correctly. How should I send @odata.readLink of each loop item to the update action?

export default function myFunction(clientAPI) {

var readPromise = clientAPI.read('MyOdataS.service', 'MyEntity',[],`$filter=is_deleted ne true`);

return readPromise.then((result) => {

for (var i = 0; i < result.length; i++) {

var item = result.getItem(i);

let picBinding = {

'@odata.readLink': item['@odata.readLink']

};

let pageProxy = clientAPI.getPageProxy();

pageProxy.setActionBinding(picBinding);

clientAPI.executeAction('MyUpdateEntity_D.action');

}

return;

});

}

//MyUpdateEntity_D.action

{

"_Type": "Action.Type.ODataService.UpdateEntity",

"Target": {

"Service": "MyOdataS.service",

"EntitySet": "MyEntity2",

"QueryOptions": "",

"ReadLink": "{@odata.readLink}"

},

"Properties": {

"is_deleted": true

}

}