Xpages - JS code fails to execute when clicked via a button

87 views Asked by At

I have a strange issue, where I have a simple javascript button, that call's 1 function to write some document history and replace the value of one field. It then does a partial update of a container div ID.

This button works fine when accessed via the UK, however when used by Swiss colleagues, the button is doing nothing.

I have in 1 instance, witnessed it not working for 1 user, only for it to suddenly work later in the day, so I'm stumped as to what the issue may be.

Button Code

<xp:button id="btnProceed" styleClass="btn btn-primary" value="Proceed">
            
    <xp:this.disabled><![CDATA[#{javascript:try{
    if (getComponent("chkConfirmed").getValue() == "false") {
        return true;
    } else {
         return false;
    }
 }catch(e){
openLogBean.addError(e,this);
}
}]]></xp:this.disabled>
    <xp:eventHandler event="onclick" submit="true" refreshMode="partial"
        refreshId="contentWhiteBackground">
        <xp:this.action><![CDATA[#{javascript:var dt = new Date();
var arrHistory:array = AddIndepConfirmationHistoryItem(currentDocument, dt, "Confirmed understanding of the opening guidance", userBean.displayName);
document1.replaceItemValue("showIntroduction", "2");
document1.save();
}]]></xp:this.action>
    </xp:eventHandler></xp:button>

Called code

Sub AddIndepConfirmationHistoryItem(confdoc As NotesDocument, dt As Variant, action As String, usrname As String)
    Dim hlist As StringList
    
    If Len(confdoc.History(0)) = 0 Then
        confdoc.History = IndepConfirmationHistoryItem(dt, action, usrname)
    Else
        Set hlist = New StringList(confdoc.History, "")
        Call hlist.Append(IndepConfirmationHistoryItem(dt, action, usrname))
        confdoc.History = hlist.Items
    End If
End Sub

EDIT:

function AddIndepConfirmationHistoryItem(doc, dt, action, username){

var ArrDocHistory:array = doc.getItemValueArray("History");

var dateTimeFormat = new java.text.SimpleDateFormat("dd/MM/yyyy kk:mm");
var dateTimeString = dateTimeFormat.format(dt);


    if(ArrDocHistory.length < 1){
        // This should always return an object as it is created when an objectives document is first 
        // created but do this check to be safe and create an array if for some reason it doesnt exist
        ArrDocHistory = [dateTimeString+"|"+action+"|"+username];
    }else{
        // append new value to the array
        ArrDocHistory.push(dateTimeString+"|"+action+"|"+username);
    }
    doc.replaceItemValue("History",ArrDocHistory);
    doc.replaceItemValue("LastUpdatedByName",username);
    doc.replaceItemValue("LastUpdatedDate",dt); 
    //doc.Save();
}
0

There are 0 answers