Global Content replace using groovy console
Hi Team,
we are in AEMasCS, we are trying the update a Text content across our global pages, for that we are using sling pipes,i downloaded the package of groovy script from below git hub Github link and installed in my local. here is my groovy script,when i tried to execute the script im getting user permisson issue though groovy-console-system-user have all access please find below screenshot. Kindly help on this.


groovyscript
=====
import org.apache.sling.api.resource.ResourceResolver
import org.apache.sling.api.resource.ResourceResolverFactory
import org.apache.sling.pipes.Plumber
import org.apache.sling.pipes.PipeBindings
// Get the ResourceResolverFactory service
def resourceResolverFactory = getService(ResourceResolverFactory)
def plumber = getService("org.apache.sling.pipes.Plumber");
// Define the path to the content you want to update
def contentPath = "/content/wknd"
// Define the text to find and replace
def findText = "helloworld"
def replaceText = "updated helloworld"
Map<String, Object> param = new HashMap<>()
param.put(ResourceResolverFactory.SUBSERVICE, "sling-pipes-user")
ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(param)
try {
// Create a new pipe
println resourceResolver.getUserID()
def pipe = plumber.newPipe(resourceResolver)
.echo(contentPath) // Start at the content path
.xpath("/jcr:root${contentPath}//element(*, nt:base)[jcr:contains(., '${findText}')]") // Find nodes containing the text
.write("jcr:title", replaceText) // Replace the text in the jcr:title property
.run()
// Execute the pipe
plumber.execute(resourceResolver, pipe, null)
println "Text replacement completed successfully."
} catch (Exception e) {
e.printStackTrace()
println "An error occurred: ${e.message}"
} finally {
resourceResolver.close()
}