1

I have a strange issue, that only affects some users.

I have a custom control on an xpage, which contains a modal, within which is a date time picker based on this: https://xpagesandmore.blogspot.co.uk/2014/09/using-bootstrap-datetimepicker-in-xpages.html

When some users click the following save button, the page refreshes, but no changes are saved:

    <xp:button value="Save Changes" id="button8"
            styleClass="btn-header">
            <xp:this.rendered><![CDATA[#{javascript:try{

    var strOwner:string = document1.getItemValueString("owner");
    var strStatus:string = document1.getItemValueString("status");
    var booVisible:boolean = false;
    var booOwner:boolean = false;
    var booStatus:boolean = false;

    if (userBean.displayName==strOwner){
        booOwner = true;
    }

    if(strStatus=="Objectives Completed" || strStatus=="Self Assessment Due"){
        booStatus = true;
    }

    if (document1.isEditable()&& booOwner && booStatus){
        booVisible = true;
    }

    return booVisible;

    }catch(e){
        openLogBean.addError(e,this);
    }}]]></xp:this.rendered>
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action>
                    <xp:actionGroup>

                    <xp:executeScript>
                            <xp:this.script><![CDATA[#{javascript:try{

    var dt = new Date();

    var arrHistory:array = AddObjectivesHistoryItem(currentDocument, dt, "Saved", userBean.displayName);

    document1.replaceItemValue("rows",viewScope.rows);
    var o = {}
    o.title = "Document Saved";
    o.body = "This document has been succesfully saved";
    o.alertIcon = "fa-thumbs-up fa-lg";
    o.autoClose = true;
    o.alertType = "success";
    //o.growl = true;
    requestScope.put("alertServer",o)
    document1.save();
    context.reloadPage();
    }catch(e){
        openLogBean.addError(e,this.getParent());
    }}]]></xp:this.script>
                        </xp:executeScript>
                    </xp:actionGroup>
                </xp:this.action>
            </xp:eventHandler>
        </xp:button>

For me, it works (maybe as I have admin rights?)

But if I remove the custom control, it works for everybody. My thinking is there is an error with the scripts on my custom control, code is:

<xp:this.resources>
        <xp:headTag tagName="script">
            <xp:this.attributes>
                <xp:parameter name="type" value="text/javascript" />
                <xp:parameter name="src"
                    value="moment210/moment-with-locales.js" />
            </xp:this.attributes> 
    </xp:headTag>

        <xp:script
            src="bootstrapdatetimepicker4/js/bootstrap-datetimepicker.js"
            clientSide="true" />
                    <xp:styleSheet
            href="bootstrapdatetimepicker4/css/bootstrap-datetimepicker.css" />
    </xp:this.resources>

    <xp:this.data>
        <xp:dominoDocument var="document2"></xp:dominoDocument>
    </xp:this.data>


    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[$(document).ready(
    function() {
        x$( "#{id:datetimepicker1}" ).datetimepicker({
            locale: 'en-gb',
            showTodayButton:true,
            showClose: true,
            daysOfWeekDisabled: [0,6],
            format:('DD/MM/YYYY')
    });
});
]]>
        </xp:this.value>
    </xp:scriptBlock>

                <!-- Modal ONE -->
    <div class="modal fade" data-keyboard="false" data-backdrop="static"
        tabindex="-1" role="dialog" id="modalDueDate">

        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header modal-header-default">
                    <h4 class="modal-title">Change Due Date</h4>
                </div>
                <div class="modal-body">


<div class='input-group date'
       id='datetimepicker1'>
       <xp:inputText id="dtChangeDueDate" styleClass="form-control"
        value="#{document2.DueDate}" style="height:34px">
        <xp:this.attrs>
            <xp:attr name="data-date-format" value="DD/MM/YYYY">
            </xp:attr>
            <xp:attr name="placeholder" value="Enter data"></xp:attr>
        </xp:this.attrs>
        <xp:this.converter>
            <xp:convertDateTime type="date" dateStyle="short">
            </xp:convertDateTime>
        </xp:this.converter>
       </xp:inputText>
       <span class="input-group-addon">
        <span
         class="glyphicon glyphicon-calendar">
        </span>
       </span>
      </div>

                </div>

                <div class="modal-footer">
                    <xp:button type="button" styleClass="btn btn-danger"
                        id="button4">

                        <xp:this.attrs>
                            <xp:attr name="data-toggle" value="modal" />
                            <xp:attr name="data-target"
                                value="#modalDueDate" />
                        </xp:this.attrs>
                        Cancel

                    </xp:button>

                    <xp:button type="button" styleClass="btn btn-success"
                        id="button5">

                        <xp:this.attrs>
                            <xp:attr name="data-toggle" value="modal" />
                            <xp:attr name="data-target"
                                value="#modalDueDate" />
                        </xp:this.attrs>
                        Update

                        <xp:eventHandler event="onclick" submit="true"
                            refreshMode="complete">
                            <xp:this.action><![CDATA[#{javascript:try{

var noteID:string = compositeData.noteID;
var doc:NotesDocument = database.getDocumentByID(noteID);
var dueDate = getComponent("dtChangeDueDate").getValue();

var docWrap = wrapDocument(doc);

var dateTimeFormat = new java.text.SimpleDateFormat("dd/MM/yyyy");
var dateTimeString = dateTimeFormat.format(dueDate);

var dt = new Date();
var arrHistory:array = AddObjectivesHistoryItem(docWrap, dt, "Due Date Changed To "+dateTimeString, userBean.displayName);

docWrap.replaceItemValue("DueDate",dueDate);
docWrap.save();

var o = {}
o.title = "Due Date Updated";
o.body = "The due date has been succesfully updated to " + dateTimeString;
o.alertIcon = "fa-thumbs-up fa-lg";
o.autoClose = true;
o.alertType = "success";
//o.growl = true;
requestScope.put("alertServer",o);
context.reloadPage();

}catch(e){
    openLogBean.addError(e,this.getParent());
}}]]></xp:this.action>
                        </xp:eventHandler></xp:button> 

                </div>
            </div>
        </div>
    </div><!-- Modal ONE End-->

There are no errors in the log, no errors on the screen, and no errors on the server console, or when using DEV tools in the browser, so I can't pin point the issue.

The URL of the document can be different depending on where the user has come from, for example, it can be:

/ppg/aqo.nsf/%24%24OpenDominoDocument.xsp?documentId=60D9F30F3098008A80258266003BA63F&action=editDocument

OR

/ppg/aqo.nsf/xpObjectives.xsp?documentId=FBC1DB984CD8A25880258266003BAE1A&action=editDocument

Could the scripts maybe not be loading or referenced from one URL compared to the other? Is there a better way for me to include these scripts, and make sure they work across all URL's?

Any pointers appreciated.

Thanks

Chris Richards
  • 695
  • 5
  • 14
  • Maybe validation error? Use Display Error control a make sure it refreshes after that request. Especially date format may be user specific. – Frantisek Kossuth May 02 '18 at 09:17

1 Answers1

0

Could It be the ACL rights of the user? ie Create Documents, Author or higher?

Mike Zens
  • 89
  • 10
  • Hi Mike, the default access is Author, with create documents, write public documents, and replicate or copy documents – Chris Richards Apr 30 '18 at 10:36
  • Chris - Do you have Anonymous as a User and if so are they allowed rights as required if on the web? – Mike Zens Apr 30 '18 at 12:43
  • Hi Mike, Anonymous is listed with No Access. Users are all authenticated correctly, using AD so no user would ever get in as Anonymous? – Chris Richards Apr 30 '18 at 16:27
  • If you mean that the Notes Document being written to isn't saving the changes made, it could be that the document has an author field and if that person isn't listed in the author field or a Role they have in the database isn't, then they can't update it. I sometimes have to go into the ACL of the database, click effective access and then type in the user name as they use to access the database and check what rights they have. This might help you debug as to why. – Mike Zens Apr 30 '18 at 17:21
  • Hi Mike, users have author access to the database at an ACL level, and are named in the authors field on the document – Chris Richards May 01 '18 at 10:24