PD Sheehan Expert

Comments

  • This is equivalent to pasting the content on foo/bar.groovy into the console and hitting run. The only way to pass parameters to such a script is to use the "dynamic form" feature Looking at browser network call when you hit run, you can see that the payload includes 2 elements. A "parameters" json and the script string or…
  • That's possible, but you'll have to keep your country/user association right in the script. Something like this: import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.option.LazyLoadedOption def countryUserMap = [ countryName1:user1, countryName2:user2, //etc ] def categoryCf…
  • Try parsing the poa value as-is by providing the existing format (rather than converting), then format it in the desired format. new Date().parse( 'MMMM_yyyy',FirstPOA1 as String).format('MM/dd/yyyy')
  • While you can run a scripted listener on "User Created Event" I don't think there is anything in that event or in the user object that can tell you whether or not the creation was done via the REST API, or via the UI, or via some other integration. The only way would be to create your own REST Endpoint (different than the…
  • Delete the server-side script. Then create it again, and use the File Tab (above the script box, aligned right). You might be able to just delete all the text in the script box... but with some older versions of scriptrunner, that didn't always work to enable switching to "File" Make sure your field doesn't have…
  • In the behaiour code, you can use convertToSingleSelect or convertToMultiSelect The first one will convert a text custom field into a single select dropdwown. While the second one will convert a text custom field into a multi select control (behaves a bit like a label field). In the multi select option, the user has to go…
  • For behaviour to react to a change in the amount field, you must place a script on that field too. Make your script generic then place it in both the components and the amount field: import com.atlassian.jira.bc.project.component.ProjectComponent import com.onresolve.jira.groovy.user.FieldBehaviours import…
  • That's what if(components.any{it.name in ['Refund','OtherComponent']}){ should do. If the name of any of the select components are part of the list [Refund, Other] then run the next line. import com.atlassian.jira.bc.project.component.ProjectComponent import com.onresolve.jira.groovy.user.FieldBehaviours import…
  • Assuming this app global permission are stored like all the other global permissions, you should be able to use https://docs.atlassian.com/software/jira/docs/api/8.13.6/com/atlassian/jira/security/GlobalPermissionManager.html With Scriptrunner console, print the list of permission keys: import…
  • I think it will be easier to combine those values in the groovy part of the script rather than in SQL. Make your sql "Select FirstName, LastName FROM Person where FirstName like ?" Then create your item object like this: def fullName = "$row.FirstName $row.LastName" as String [ value: fullName,…
  • Since each field update event should trigger a change in the summary, I think the best solution is to store your script in your script root and apply the same script field in each field. The alternative, is to force users to fill in the fields in a certain order and trigger the update on the last one only. I think that's…
  • So, does this new version of the script work when you select component Refund? It looks to me like it should. And are you asking how to change that to work with Refund +anotherComponent? If so, then you can change if(components.any{it.name == 'Refund'}){ to if(components.any{it.name in ['Refund','OtherComponent']}){
  • Ok, I had to doa bit of debugging on my end ... but ultimately... something I suggested that made the static type checking error go away was not correct and prevented the script from running. I was able to get this to run in my environment: import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import…
  • So, we now know for sure that the issue is not with getting data from the DB. Let's plug some more logs in the REST API to figure out why the DB results are not loaded in the rt.items Try to update your restapi code with this: import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import…
  • I think you can do this all within insight automation. * Go to your insight object schema configuration page and navigate to the Automation tab. * Create a new rule * Give it a name, description and some user with permission to change attributes * Add a trigger* Trigger = Scheduled Event * Condition = objectType= XXX and…
  • The actual logic for this is fairly simple ... what's hard is to get the Category values and then update another attribute. With the utility class I created (see this article) I can achieve your requirement with this script in the insight groovy console: import com.atlassian.jira.component.ComponentAccessor import…
  • What do you get if you run the following in your console? import com.onresolve.scriptrunner.db.DatabaseUtil DatabaseUtil.withSql('Mysql_Customerdb'){ sql-> sql.rows('SELECT FirstName, LastName from Person WHERE FirstName like ?', ["%Victor%" as Object]) }
  • Regex will be your friend for that. I often use this for reference: https://regex101.com/r/1BscV3/2 Here is how you can use that in groovy: def labels = ['June_2019_POA1', 'ABC', 'July_2020_POA2', 'XYZ'] def regexPat = /^([a-z|A-Z]*_\d{4})_(\S*)$/ def fieldMap = [POA1:'FirstPOA1', POA2:'SecondPOA2'] def FirstPOA1,…
  • I haven't used or tested the round robin script. But I have some concern about performance on projects with lots of issues. The more issue to have the more issues you have to sort and reverse. (Since this deals with just a list of long integer, it may not be a valid concern in most normal use case) But given that concern…
  • What happens when you point your browser to this?<jiraBaseUrl>/rest/scriptrunner/latest/custom/eventTypes Are you getting some data? What about with this? <jiraBaseUrl>/rest/scriptrunner/latest/custom/eventTypes?query=Victor Then you can try adding some logs to your restapi Something like : /* ...*/ def query =…
  • A few pointers 1) these static error checking don't necessarily the code is bad. Just to review because the checker is unable to be sure. The real test is what happens when you deploy and call the new API 2) You will have a cleaner implementation of the sql query if you use the Resources functionality of scriptrunner 3)…
  • Sorry, my bad You need to convert the Date to a Timestamp before assigning it to a field: issue.setCustomFieldValue(startTime, dateStart.toTimestamp())
  • Here is an example var customField = AJS.$('#html-id-of-the-field-in-your-dialog'); var issueKey = ''; //you'll need some way to access the issue. Maybe add a hidden field in your dialog AJS.$.ajax({ type: "PU", dataType: "json", "contentType": "application/json", headers: { "X-Atlassian-Token": "no-check" }, data: {…
  • Jira stores all date/time fields in the db as timestamp values which are essentially the UTC EpochMilliseconds. So that means that 4am for you may not be 4am for every user. If you set the value to 4am server time, the equivalent UTC timestamp will be stored, and then other users in other timezones will see different…
  • In the current version of your script, you have 2 separate conditions in 2 separate lines, but only the last one counts. Maybe rearrange things a little like this: import com.atlassian.jira.component.ComponentAccessor def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser def projectList= ['ITS'] def…
  • For anyone following this thread, I've added a createObject() method.
  • By defaults, insight assets on the customer portal are only visible via a custom field on the request create form. In our environment, since we also have Refined Wiki, I used a combination of a Scriptrunner Customer REST Endpoint and some javascript in a Refined HTML Content block to display some assets in a table. But…
  • @Jesse Jenken does that still work for you? We had a similar URL mask in our Gmail for our Jira Server instance, but lately, that doesn't work in chrome When I look at chrome developer tools, I can see a request */secure/attachment/*.png are getting a 302 status code and redirected to the login page. This implies that…
  • Let's try to break it down with a simpler script ... Can you try this and get the full result (the full stack trace if you get an error)... let's see if we can find out what's happening @Grapes( @Grab(group='com.opencsv', module='opencsv', version='4.2') ) import com.opencsv.CSVReader String csv = "a,b,c" new CSVReader(new…
  • Are you familiar with the script root concept of scriptrunner? In your jira-home directory, there should be a folder called "scripts". There were all the files to create and manage with the Script Editor will go. My suggestion is to store your .js file in there. And rather than hardcoding the full path, for better…