cancel
Showing results for 
Search instead for 
Did you mean: 

Issue on Sync after using UpdateEntity Action

aanchal_kajaria
Participant

Hello experts,

This is with regards to my custom offline MDK app using # Mobile Development Kit SDK Version: 5.2.1-001

While editing notification details, data is being updated locally but the same details is not updated in the back end on sync. I am able to see the change after the UpdateEntity action is called and on return to the Notification list page. Opening the same notification now shows the changed values in the Notifications details page. But after sync, when I check in the backend, the notification is created with the old values only(ones which were selected during notification CreateEntity action). I see no errors from ErrorArchive also.

I think this was a known issue in older version of MDK client, but not able to figure out why this happens now. Please help check.

Thanks and regards

Aanchal

Accepted Solutions (1)

Accepted Solutions (1)

mingkho
Advisor
Advisor

Hi Aanchal

To summarize this so that others can benefit from the answer:

The reason your updated entity value is not reflected is because the PMNOTIFICATIONSE_UPDATE_ENTITY is not implemented in your backend, hence the update entity request is not getting processed.

That because when created an entity locally (ProductName=Product1) and then modify it with update entity action (change ProductName to Product1Modified), you will get 2 requests sent to the backend when you sync your data.

1 create request and 1 update request.

As for your use case:

Because in your use case you do not want to allow entity to be updated once the entity has been created in the backend, then your best option is to enable your OData service's OfflineOptions > StoreParameters > EnableRequestQueueOptimization to true.

This allow the offline component to optimize your requests before sending it to the backend.

e.g. If you have created an entity locally (ProductName=Product1) and then modify it with update entity action (change ProductName to Product1Modified).

With EnableRequestQueueOptimization=false (default), you'll get 2 request sent to the backend, 1 for the create (ProductName=Product1) and 1 for the update (change ProductName to Product1Modified)

With EnableRequestQueueOptimization=true, you'll get 1 request sent to the backend which is the create (ProductName=Product1Modified)

More details on Request Queue Optimization can be found here:

https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/features/offlin...

Regards

Ming

Answers (2)

Answers (2)

fjcarrasco
Active Participant

Hello Aanchal. I'd tell you that you check transaction /IWFND/ERROR_LOG in backend because maybe there is some problem with service. Are you returning the updted entity with the changes?

Also, I'd tell you do a trace network from mobile services in order to see the answer code you receive from backend to your request.

aanchal_kajaria
Participant
0 Kudos

Hello Francisco,

I checked my backend error log and there is nothing there.

I'll share few more details here:

1. I noticed the values I change in the Edit Notification page are not captured in the binding object. I could do this by putting a breakpoint in a rule which calls the UpdateEntity action.

Above you can see above the values in the binding object are M1 and 1 for NotifType and Priority, though in the app I have changed them to M2 and 2. On going back to the list and checking the notification details now, I see below correct values:

But in the backend the notification is created with old values of M1 and 1,on sync now.

2. In the backend I have just redefined the PMNOTIFICATIONSE_UPDATE_ENTITY (no logic put). As I am only required to update the notifications created in the offline store and not the ones which are created in the backend, so no code is needed. I just need to update the create requests which are in offline store.

Please let me know now, what more can be checked.

Thanks and regards

Aanchal

mingkho
Advisor
Advisor
0 Kudos

aanchal.kajaria

When you modify value in the Form Cell controls, it does not update the value inside context's binding. It does not work like that.

The modified value is stored in the Form Cell control.

So in your UpdateEntity.action your "NotificationType" and "Priority" must be assigned with value from these controls and not from your binding (because your binding will still have the original value M1 and 1).

e.g. UpdateEntity.action

"NotificationType": "#Page:XYZ/#Control:NotificationTypeControlName/#Value",
"Priority": "#Page:XYZ/#Control:PriorityControlName/#Value",

Regards

Ming

aanchal_kajaria
Participant
0 Kudos

I have this in my UpdateEntity action:

{
    "ActionResult": {
        "_Name": "update"
    },
    "OnFailure": "/ZME_CREATENOTIFICATION/Actions/UpdateNotificationEntityFailureMessage.action",
    "OnSuccess": "/ZME_CREATENOTIFICATION/Actions/UpdateNotificationSuccessMessage.action",


    "Properties": {
    
        "Equipment": "/ZME_CREATENOTIFICATION/Rules/EquipInLPOrSP.rule.js",
        "FuncLoc": "/ZME_CREATENOTIFICATION/Rules/FuncLocInLPOrSP.rule.js",
        "NotifType": "#Page:NotifEditPage/#Control:NotTypeFormCellListPicker/#SelectedValue",       
        "Priority": "#Page:NotifEditPage/#Control:PriorityFormCellListPicker/#SelectedValue",
        "ShortText": "#Page:NotifEditPage/#Control:ShortTextFormCellSimpleProperty/#Value",
        "Description": "#Page:NotifEditPage/#Control:DescriptiontFormCellSimpleProperty/#Value"
        
    },
    "Target": {
        "EntitySet": "PMNotificationSet",
        "ReadLink": "{@odata.readLink}",
        "Service": "/ZME_CREATENOTIFICATION/Services/ZME_PM_CREATE_NOTIFICATION_SRV.service"
    },

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

fjcarrasco
Active Participant
0 Kudos

I'd tell you that you need to return in the PMNOTIFICATIONSE_UPDATE_ENTITY method the entity with the same values you are receiving, same as when you create an entity.

Try to include this in your update entity method:

io_data_provider->read_entry_data( IMPORTING es_data = ls_entityset ).
er_entity = ls_entityset.

Also, usually after uploading a download is trigger, so if you don't do anything in backend when update, the download maybe is downloading the initial values and restoring them in offline DB.