Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

is it possible to find all boards connected to an inactive user with groovy? Edited

Currently i have a script the gives me all inactive users, 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager

// all inactive jira users
UserManager userManager = ComponentAccessor.getUserManager()
userManager.getUsers().findAll{user -> !user.isActive()}.each { user ->
//...
}

Now i would like to find out if the inactive user also has a board that i can remove, somewhat as below but with groovy. any ideas?

image.png

1 answer

1 accepted

0 votes
Answer accepted

Hi @Tomas Gustavsson ,

You can find it direct from DB.

SELECT * FROM ao_60db71_rapidview where owner_user_name='andrewdvizhok';

How request to DB from scriptrunner I already write here https://community.atlassian.com/t5/Jira-questions/get-all-category-created-in-jira/qaq-p/1084797

 

But unfortunately I don't know how delete it through scritrunner. I prefer use selenium to delete boards/schemes/etc in UI, because delete direct from DB or scriptrunner may break system.

B.R.

This is great, I will not delete then i just need for find what i can delete and then I will use jira for the deletion.

 

i did get an issue, maybe it is related to my jira version which is 7.6.4 i do get an error.
can you please help?


startup failed: Script44.groovy: 14: unable to resolve class Sql @ line 14, column 5. Sql sql = new Sql(conn) ^ Script44.groovy: 14: unable to resolve class Sql @ line 14, column 11. Sql sql = new Sql(conn) ^ 2 errors

Any idea why?

I have got your original Sql statment to work, the one in the link.

when adding the select statement in your answer here, i get the error message
ERROR: relation "ao_60db71_rapidview" does not exist Position: 16

Yep, in some DB used only upcases. Try 'AO_60DB71_RAPIDVIEW'.

B.R.

Like Tomas Gustavsson likes this

Is there a way to find out which columns a table as ao_60db71_rapidview holds?

i did and that seams to work, now it complain about column-name

SELECT ID, NAME FROM AO_60DB71_RAPIDVIEW where OWNER_USER_NAME='andrewdvizhok';

and in code use it.ID and it.NAME

B.R.

Like Tomas Gustavsson likes this

Super now i got it, thanks for a really great help and support

import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface

import java.sql.Connection

def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default");

def sqlStmt = """
SELECT * FROM "AO_60DB71_RAPIDVIEW";
"""
def result
Connection conn = ConnectionFactory.getConnection(helperName);
Sql sql = new Sql(conn)

try {
StringBuffer sb = new StringBuffer()
sql.eachRow(sqlStmt) {
sb << "${it.name} ${it.OWNER_USER_NAME}; \n"
}
result = sb.toString()
log.error sb.toString()
}
finally {
sql.close()
}

return result

Like Andrew likes this

Good! But careful because your code return  list all boards, not only from inactive owners. 
B.R.

Like Tomas Gustavsson likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

201 views 6 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you