Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Dublicate values in LDAP Scripted Field

Bektas Ozan Topkaya April 11, 2024

Hello Community

I have created an LDAP Scripted field "Abteilung", which shows the departments of all employees. The problem is that I can't remove the duplicate departments from this new field. Any ideas?

Thank you

Ozan


HRS1.png HRS2.png

1 answer

0 votes
Matt Parks
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 11, 2024

You could potentially write a Behavior that takes all of the field options and adds them to an array, then update that array to only include the unique options and then set that as the list of options in the field.

Bektas Ozan Topkaya April 12, 2024 edited

package Test
import com.onresolve.scriptrunner.ldap.LdapUtil
import org.springframework.ldap.core.AttributesMapper
import javax.naming.directory.SearchControls


// Keine Führungspersonen
def filter="(&(ou=IA*)(!(directReports=*)))"

def cnOU = LdapUtil.withTemplate('LDAP-User') { template ->
template.search("", filter, SearchControls.SUBTREE_SCOPE, { attributes ->
attributes.get('ou').get()
} as AttributesMapper<String>)
}

def cnOUUniqueValues = []
def cnOUSeen = []

cnOU.each { item ->
   def value = item.split(", ")[0]

        if (! cnOUSeen.contains(value)) {
             cnOUUniqueValues << item
         }

        cnOUSeen << value
         }

log.warn('OU-Liste:')
log.warn(cnOU)
log.warn('OU-Liste Unique:')
log.warn(cnOUUniqueValues)

HRS3.png

Bektas Ozan Topkaya April 12, 2024

Thanks for your advice Matt.

I am not a developer and I was able to build such a script with the help of google. I can list them in the console but I don't know how to do it in an LDAP field.

I have already tried the script for my LDAP field (through Behaviors) but no success.

I also tried the script for single select field, but I could not display any options at all

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events