Xpages - Adding anchor tag to a column in Notes view

169 Views Asked by At

I want to add a link into a column in Notesview, I saw an example at searchdomino when I tried it failed with the error "An operator or semicolon was expected but none was encountered", all other effort prove abortive.

Below is the example from searchdomino:

<a href='#' 
onClick="window.open('/"+@WebDbName+"/Employee/"+@Text(@DocumentUniqueID)+"?deleteDocument ','_new');window.location.reload()">Delete</a>

With the error:

An operator or semicolon was expected but none was encountered

enter image description here

I was able to surpress the error doing the below, but could not call the onclick event.

"<a href='#' onClick='window.open'>" + "/"+@WebDbName+"/employee.xsp?action=openDocument&documentId="+@Text(@DocumentUniqueID) + "</a>"

Your input will be appreciated.

Injecting notesview column values into html table, sample code:

 if(entryData[j].getAttribute("columnnumber") == "1") {            
    var xpageName = "page.xsp";
    var sURL = strURL[0] + ".nsf/" + xpageName + "?documentId=" + viewEntry[i].getAttribute("unid") + "&action=editDocument";

    result += "<tr> ";

    if(entryData[j].childNodes[1].childNodes.length == 0) {
        result += "<td><a href='" + sURL + "'>(NO_VALUE)</a></td>"
    } else {
        result += "<td><a href='" + sURL + "'>" + entryData[j].childNodes[1].childNodes[0].nodeValue + "</a></td>"
    }
} else {
    if(entryData[j].childNodes[1].childNodes.length == 0) {
        result += "<td>&nbsp;</td>"
    } else {
        result += "<td>" + entryData[j].childNodes[1].childNodes[0].nodeValue + "</td>"

    }
}
2

There are 2 best solutions below

0
On

You've got three levels of quoting to deal with there, so I think this is what you need:

{<a href='#' onClick="window.open('/}  + @WebDbName +  {/Employee/} +@Text(@DocumentUniqueID)+ {?deleteDocument ','_new');window.location.reload()">Delete</a>}

I.e, this is using...

  • { } for quoting the formula string value
  • " " for quoting the onClick attribute value within the formula string value
  • ' ' for the quoting the window.open argument values within the onClick attribute value within the formula string value.
0
On

If you look at the HTML code you are generating, you will see that you don't pass any arguments to window.open. Your code:

"<a href='#' onClick='window.open'>" + "/"+@WebDbName+"/employee.xsp?action=openDocument&documentId="+@Text(@DocumentUniqueID) + "</a>"

This would render something like this:

<a href='#' onClick='window.open'>/database.nsf/employee.xsp?action=openDocument&documentId=26176F6E8AC2362E3</a>

You need to move the URL inside your onClick event, like this:

<a href='#' onClick='window.open("/database.nsf/employee.xsp?action=openDocument&documentId=26176F6E8AC2362E3")'>Click this link</a>

Or why not just this: Click this link