It appears as if you are trying to combine SSJS and CSJS
The following code will not execute as SSJS
document1.save();
var x = document1.getElementById("CSI_ID").innerHTML
document1.replaceItemValue("CSI_ID", x);
document1.save();
document1 represents the XPage document data source and does not have a getElementById method
to get the value of an element in ssjs just call
var x = getComponent("CSI_ID").getValue();
to set the value use the setValue(variable); syntax
to write to the backend document use the getDocument() method of the document1 global object.