I am trying to modify the following code so when the user enters a new documentName, it will set the title and rename the document. If I uncomment the saveDocument line, it works. So I know the rest of the code is working. Can anyone see what I am doing wrong? {{groovy}} import org.xwiki.observation.* import org.xwiki.observation.event.* import org.xwiki.bridge.event.* import org.xwiki.context.* import com.xpn.xwiki.web.* import com.xpn.xwiki.* import org.apache.velocity.VelocityContext; class ProcessDocumentRenamer implements EventListener { def xwiki def context ProcessDocumentRenamer(xwiki, context) { this.xwiki = xwiki this.context = context } String getName() { // The unique name of this event listener return "ProcessDocumentRenamer" } List<Event> getEvents() { // The list of events this listener listens to return Arrays.asList(new DocumentCreatedEvent(), new DocumentUpdatedEvent()) } // Called by the Observation Manager when an event matches the list of events returned // by getEvents() void onEvent(Event event, Object source, Object data) { // Current context def crtContext = Utils.getComponent(Execution.class).getContext().getProperty('xwikicontext') // Defines the type of object that should be looked for def myObject = source.getObject("DocumentationTemplates.ProcessClass"); // If the page has an object of the specified class, we get the value of the relevant property and assign it to our documentName variable if (myObject != null) { // Defines the variable that we will later use to update the title of the document def documentName = myObject.get("processName").value // Defines the Complete name we will use later when we rename the document. def FullDocumentName = source.getWikiName() + "!" + source.getSpaceName() + "." + documentName; // If the name has changed, we need to update and rename the document. if (source.getName() != documentName) { source.setTitle(documentName) // Force the storage to keep the same version number, so that this looks like a single save event source.setMetaDataDirty(false); source.setContentDirty(false); // crtContext.getWiki().saveDocument(source, source.getComment(), source.isMinorEdit(), crtContext); crtContext.getWiki().renamePage(source, FullDocumentName); } } } } // Register against the Observation Manager def observation = Utils.getComponent(ObservationManager.class) observation.removeListener("ProcessDocumentRenamer") def listener = new ProcessDocumentRenamer(xwiki, xcontext) observation.addListener(listener) {{/groovy}} -- View this message in context: http://xwiki.475771.n2.nabble.com/Looking-for-help-with-groovy-tp7589782.htm... Sent from the XWiki- Dev mailing list archive at Nabble.com.