Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Remove list of pages using groovy script

Avatar

Avatar
Level 1
gayatrik8153299
Level 1

Likes

0 likes

Total Posts

25 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
gayatrik8153299
Level 1

Likes

0 likes

Total Posts

25 posts

Correct Reply

0 solutions
View profile
gayatrik8153299
Level 1

10-09-2020

Hi All,

We have some list of pages in an array and need to remove all those pages from the list.

Ex:

def list =["/content/we-retail/us/en/test1","/content/we-retail/be/en/test1","/content/we-retail/us/en/test2","/content/we-retail/be/en/test2"]

 

We tried with below code but it is not working.Could you please assist on this asap.

 

def buildQuery(list)
{
def queryManager = session.workspace.queryManager
def statement = 'SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE (node, "/content/we-retail") and name()=\'' + list+ '\'';
queryManager.createQuery(statement, 'sql')
}
def list =["/content/we-retail/us/en/test1","/content/we-retail/be/en/test1","/content/we-retail/us/en/test2","/content/we-retail/be/en/test2"]
final def query = buildQuery(list)
final def result = query.execute()
if(result.nodes.size()!=0){
result.nodes.each { node ->
if(node.contains(list))
{
node.remove()
save()
println "removed:"+list
}
}
}

 

@kautuk_sahni 

View Entire Topic

Avatar

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct Reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct Reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
aemmarc
Employee

10-09-2020