cancel
Showing results for 
Search instead for 
Did you mean: 

Kapsel App: Cannot modify local entity in offline store

Former Member
0 Kudos

Hi all,

I am facing a problem with editing an offline entity.

Actually I can add the entity to my offline store without any issue. This works more or less like the following lines show.

var request = {

            headers : oHeaders,

            requestUri : appointmentURL,

            method : "POST",

            data : oAppointment

};

OData.request(...);

The oAppointment contains just some data like description, account, contact, etc.

Once the appointment is created offline it is accessable via an URI looking like this:


"http://10.157...:8080/appID/AppointmentSet(lodata_sys_eid=X'60994DF02A2511E58000F93EFBE65E2B00000000')"

So after that I try to modify the appointment like this:

var request = {

            headers : oHeaders,

            requestUri : appointmentURL,

            method : "PUT",

            data : oAppointment

};

OData.request(...);

Now the Error occurs and just says: "Request failed".

I pretty much think the request fails because of the missing GUID of the appointment entity. But actually the GUID will only be created at the host system. And as long as I am working offline I dont have access to this host system...

Does someone has a workaround?

Thanks a lot for helping!

regards,

Clemens

Accepted Solutions (0)

Answers (1)

Answers (1)

midhun_vp
Active Contributor
0 Kudos

Hi Clemens,

Are you trying to edit an existing entity in the backend ? Make sure you are passing all the required parameters to do operation.

If you are trying to edit an entity which is not present in backend but present in your offline store might be cause an issue.

Regards,Midhun

SAP Technology RIG

Former Member
0 Kudos

Hi,

Thanks for such a fast reply!

Actually the entity is not present in the backend but only in the offline store.

The intention is that I try to add a appointment when I am offline. But I would like to be able to modify this appointment as long as I am offline.

Later on (when beeing online again) I flush the changes.

regards, Clemens

Former Member
0 Kudos

Hi Clemens,

you could try to perform a batch request on the offline store  for the scenario which you have mentioned above.

1.Create an appointment when your are offline and add this request to batch and send this batch request .

2. Read the offline store data to verfiy your request has been created

3. Modify your request ,add this to batch and send this batch request.

4. Later on being online flush your changes.

Hope this helps.

Thanks,

Latha

Former Member
0 Kudos

Hi Latha,

Thanks for your support!

I followed your instruction step by step but unfortunately this didn't work as well. The same error appears: "Request failed".

Just to make sure I understood everything right here is the corresponding code:

Step1 Add:

        var params = {

                __batchRequests: [ {

                    __changeRequests: [ {

                        requestUri: saveAppointmentsURL,

                        method: "POST",

                        data : oAppointment

                    }

                    ]

                }

            ]

        };

       

        var request = {

            headers : oHeaders,

            requestUri : applicationContext.applicationEndpointURL + "/$batch",

            method : "POST",

            data : params

        };

       

        OData.request(...);

Step3 Modify:

        var params = {

                __batchRequests: [ {

                    __changeRequests: [ {

                        requestUri: updateAppointmentsURL,

                        method: "POST",

                        data : oAppointment

                    }

                    ]

                }

            ]

        };

       

        var request = {

            headers : oHeaders,

            requestUri : applicationContext.applicationEndpointURL + "/$batch",

            method : "PUT",

            data : params

        };

        OData.request(...);  

former_member220979
Participant
0 Kudos

Hi Clemens,

Did you able to found the solution?

Thanks,

Chirag.

Former Member
0 Kudos

Hi Chirag,

Yes and no...

I started using the GUID when creating an entity. Because the WebService didn't accept foreign GUIDs I also had to change the WebService to get rid of this issue.

regards,

Clemens

former_member220979
Participant
0 Kudos

Hi Clemens,

Can you please let me know briefly what are the changes required for web services?

Thanks,

Chirag.

Former Member
0 Kudos

Hi,

The WebService now accepts a GUID, which wasn't created by the system.

regards,

Clemens