cancel
Showing results for 
Search instead for 
Did you mean: 

Kepsel Offline oData - How to download offline attachments

I am currently attempting to implement downloading of offline attachments with my app.

I have configured a defining request pointing to my attachments entity with retrieveStreams = true

"Attachments" : {"url" : "/zdod_i_attachments", "retrieveStreams" : "true"}

However, on initial opening of the store I receive a sync error. Checking mobile services, I can see that the app attempted to call:

<service_root> + <service_name>/<file_name>

The app appears to be attempting to download all attachments on store open. I assume I need to use the function registerStreamRequest, however I am unsure where in the application lifecycle this needs to be called and if I need to make the function call for each individual attachment

Below is a sample call:

 sap.hybrid.store.registerStreamRequest("stream",
        	"/zdod_i_attachments(incidentId=guid'" + "c4113ba7-6c91-4e6e-a816-d033e54bfcc" + "',attachmentId=guid'" + "061836cc-5e27-1ed8-beb9-30c5092e42c6" + "')",
        	sap.hybrid.onRegisterStreamSuccess, sap.hybrid.onRegisterStreamError);

Then in the success callback I trigger a refresh:

	onRegisterStreamSuccess : function(){
		sap.hybrid.store.refresh();
	},

How can I make sure the store attempts to call the right path pointing to the attachment entity?

Thanks,

William

Accepted Solutions (1)

Accepted Solutions (1)

mgrasshoff
Advisor
Advisor
0 Kudos

Hi,

I can see multiple questions here:

1) Do I need to register/unregister for each attachment?

Unfortunately, yes. This impacts the answer to 2)

2) When to call the download of an attachment?

Whenever you need to get it, it's up to you to decide.

Does the .refresh() works for you and you can download and refresh the attachment?

Note (it's boolean not string):

"retrieveStreams" : true

Related documentation can be found here (for other readers, you already found it)

https://help.sap.com/viewer/42dc90f1e1ed45d9aafad60c80646d10/3.1.3/en-US/e718313cb91c4b9b8ac0ab8121c...

Hope this helps a bit.

Regards,

Martin

Answers (0)