Problem with saving datasource

I have a page with multiple custom controls, including several repeat controls. For one of them which contains as repeating elements both text fields and attachments from the associated back-end document (bound with action=“editDocument”), I want to have the ability to edit and save those textual fields.

To accomplish this, I have the requestScope variable that renders the fields as editable only for a new document or when I click on my “edit doc” button, otherwise as “read only”. When I just create a new doc, it saves the text values with MyDoc.save() in SSJS with no problem. However, when I hit “edit doc” button and it opens those fields for editing (with proper values from the backend), I can’t save it back with either of the following methods:

  1. MyDoc.save()

  2. global Save()

  3. directly setting the values form UI to fields of the backend doc and save it (in SSJS)

Back-end doc doesn’t have any security features like authors fields and the authenticated user on web has all rights to edit the doc.

Question is: what might be the reason for such a weird behavior of the Xpage?

Subject: Re: Problem with saving datasource

I would suggest a couple of things to start off with. Firstly, is it hitting an error with saving? On the XPage tab of the XPage itself you can specify the page to load on success or failure. You can quickly answer this question by temporarily directing it to a different XPage on failure.

Secondly, instead of rendered editable fields and a default action of editDocument, how about setting the default action to OpenDocument and using an action button to run a server-side basic action to change mode to edit mode. Bear in mind that with 8.5.1 there was a known bug that meant you needed to double-click the edit button if it was within an Editable Area. If it’s directly on the XPage, single-click works. I’m informed this is fixed in 8.5.1 FP1.

Subject: Resolved!

Thanks Paul, that was very helpful. First, I tried testing for errors using the method you described, and there were none. Second, I used the variation of your approach and switched the default action to computed value, which evaluates to “openDocument” or “editDocument” depending on the scope variables which I set with my buttons. In this case, simple action “save document” works perfectly! Magic of the forum works again…