0 Votes

Changes for page Script

Last modified by Ryan C on 2025/05/13 16:08

From version 11.1
edited by Ryan C
on 2025/05/13 16:04
Change comment: There is no comment for this version
To version 10.1
edited by Ryan C
on 2025/05/13 16:03
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -3,7 +3,7 @@
3 3  
4 4  // References
5 5  def groupDocRef = new DocumentReference("xwiki", "XWiki", "XWikiAllGroup")
6 -def groupClassName = "XWiki.XWikiGroups" as String // Force string type!
6 +def groupClassName = "XWiki.XWikiGroups" // ⚠️ Must be a STRING
7 7  
8 8  // Load or create the group page
9 9  def groupDocAPI = xwiki.getDocument(groupDocRef)
... ... @@ -24,13 +24,13 @@
24 24   }
25 25  
26 26   if (!alreadyMember) {
27 - def obj = groupDoc.newXObject(groupClassName)
27 + def obj = groupDoc.newXObject(groupClassName) // ✅ String only
28 28   obj.setStringValue("member", userDocName)
29 29   added << userDocName
30 30   }
31 31  }
32 32  
33 -// Save if needed
33 +// Save the document
34 34  if (added) {
35 35   def wrappedDoc = xwiki.getDocument(groupDoc.documentReference)
36 36   xwiki.saveDocument(wrappedDoc, "Added users to group: ${added.join(', ')}")