This Line Causes the Script to Fail - I can read from the object (get) but I cant “Set” the property
SHPQUALITYObject.set("closed_dt", xwiki.getDate())
I know this because the comment isnt updated and the attribute of the object isn’t set.
Full Script (with suggestions added) Same issue as before
{{groovy}}
def docSource = xcontext.method.input.get(1)
def SHPDocObject = docSource.getObject("SHPDocuments.SHPDocumentClass")
if (SHPDocObject) {
//Lets See if its in Status Control
def SHPQUALITYObject = docSource.getObject("SHPQUALITY.SHPQUALITYClass")
if (SHPQUALITYObject) {
//Get the status of This Document (the one thats changing)
def newStatus = SHPQUALITYObject.get("status").value
//Get the old Document (the one that already exists if there is one )
def oldDoc = docSource.getOriginalDocument()
def oldSHPQUALITYObject = oldDoc.getObject("SHPQUALITY.SHPQUALITYClass")
def oldStatus = oldSHPQUALITYObject.get("status").value
if (newStatus == "Closed") {
// Set Closed Date as today
SHPQUALITYObject.set("closed_dt", xwiki.getDate())
//Append the Comment
docSource.setComment("CLOSED")
}
}
}
{{/groovy}}