# Appendix F -- JavaScript

Custom Control zcontent_DocCode contains a sample of some commonly used JavaScript code. In addition, the following links connect to web pages containing sample code for the various JavaScript commands available for XPages:

1
2 var doc:NotesDocument = document1.getDocument(true)
viewScope.test01 = doc.getItemValueString("Field11")
3 viewScope.test02 = document1.getValue("Field11")
4 getComponent("Field11").setValue("ServerSide JS")
5 viewScope.getXPFieldSSJS = getComponent("Field11").getValue()
6 var element = XSP.getElementById('#{id:Field11}')
element.value = "Client SideJS"
7 var myVar = document.getElementById("#{id:Field11}").value
var element = XSP.getElementById('#{id:Field11}')
alert(myVar)
alert(XSP.getFieldValue(element))
8 var myVar = document.getElementById("#{id:backendValueEL}").innerHTML
alert(myVar)
9 var userResponse = prompt("Please enter your response:","<response>")
XSP.getElementById("#{id:userResponse}").value = userResponse
10 var doc:NotesDocument = document1.getDocument(true)
var docVirtual = database.createDocument()
var agent:NotesAgent = database.getAgent("(sampleAgentCallFromXPages)")
docVirtual.replaceItemValue("TestField", doc.getItemValue("Field12")) agent.runWithDocumentContext(docVirtual)
document1.setValue("Field12", docVirtual.getItemValue("TestField"))
Last Updated: 5/5/2019, 9:33:44 PM