Hi,
I am trying to create a job function to read a csv file and update user properties based on that. I don't want to do it via the REST API because the properties set by the API are not usable in post-function.
I want add the manager of all my users. Those data are present in a csv with 2 columns : user | manager
On the job, the line "
userPropertyManager.getPropertySet(row.user)?.setString('jira.meta.'+propertyKey, row.manager);" is not working, any guess why ?
Here is the full script :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
import com.mindprod.csv.CSVReader
def filePath = '/home/jira/atlassian/application-data/jira/scriptrunner/user_test.csv'
def reader = new CSVReader(new FileReader(new File(filePath)))
//Gets the user property value based on the key.
def propertyKey = 'manager'; //Property name
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager();
def data= reader.collect { it }.with { rows ->
def header = rows.head()
def dataRows = rows.tail()
dataRows.collect { row ->
[header, row].transpose().collectEntries()
}
}
data.each{row->
userPropertyManager.getPropertySet(row.user)?.setString('jira.meta.'+propertyKey, row.manager);
// access any data from the row by the name of the header
// for example, row['colHeader'] or row.colHeader
}
Thanks in advance