1 answer
- 210
Hi Charlie Schonken
Thanks for your question (and an alternative name for John Doe)
Assuming you use a scripted connection
You can filter out the comments from Joe in your outgoing sync by addingUntestedreplica.comments = issue.comments.findAll { comment -> comment.author.name != "Joe Soap" }
- Francis Martens (Exalate)
PS - whenever in doubt - use the groovy console to try out some constructs
https://groovyconsole.appspot.com/ - Francis Martens (Exalate)
You can check on the properties of the comment by adding in the closuredebug.error("Comment properties = ${comment.properties}")
Or check the documentation 'Comment'
And then add the condition such ascomment.author.name != "Joe Soap" && comment....
Give it a try.
- Charlie Schonken
Hi Francis Martens (Exalate) - thank you for the continued assistance.
Let me frame it ... I am a newbie at this scripting thing, and I fear im not the best at understanding everything.
I did not know how to "AND" different conditions, which you now highlighted as "&&" ... that is extremely helpful thankyou.
I noted from the Comment documentation that there is a CREATED property.
I am not 100% sure how to use it in terms of the date format to be used.
I want to state that comment.created > "24 November 2021" but not this seems wrong, or is it?
in other words it must only look at comments after 24 November. - Charlie Schonken
also the debug thing ... i added it to the script ... but entirely pointless ... it doesnt show me anything meaningful except a error trace ... and all that says is "No such property: comment for class: Script100" on line 18 ... which is the debug line. So no idea what its supposed to do.
- Francis Martens (Exalate)
OK -
"24 november 2021" is not a date but a string and comparing apples with pears is also not possible even if you're a computer. Luckily our best friend google points to an article
https://stackoverflow.com/questions/45099374/how-to-compare-date-in-groovy
for details on how to compare dates.
Regarding the debug statement - did you add it in the closure like in. The closure is the block delineated with curly brackets ({}) after findAll
replica.comments = issue.comments.findAll { comment -> comment.author.name != "Joe Soap" debug.error("Comment properties = ${comment.properties}") }
I can understand that there is a learning curve to go through scripting.
There are resources available online to learn on how to do such things, or exalate has today 126 partners which can help with the implementation and get your integration configured faster than writing up the whole thread. - Charlie Schonken
Hi Francis Martens (Exalate)
Sorry ... maybe it's me.
I have now literally copied your script from abovereplica.comments = issue.comments.findAll { comment -> comment.author.name != "Joe Soap" debug.error("Comment properties = ${comment.properties}") }
and now I still get an error saying No such property: name for class: com.exalate.basic.domain.hubobject.v1.BasicHubUser on line 19 ...
Line 19 is the comment.author condition
Maybe the app just doesnt like me
- Francis Martens (Exalate)
Let's no go there, we get in trouble if computers starts to have feelings.
The reason why it doesn't work is because author.name doesn't exist. I made the mistake not to look up the attributes for a user (here)
It should be comment.author.displayName ...
(I didn't tested my suggestion) - Charlie Schonken
lol Francis Martens (Exalate)
Humor helps.Ok, I have now edited the script as follows ...
replica.comments = issue.comments.findAll { comment -> comment.author.displayName != "BigPicture - for ppm, project management" && comment.created > new Date().parse("dd MMM yyyy HH:mm:ss", "25 Nov 2021 00:00:01") debug.error("Comment properties = ${comment.properties}") }
Note: Excluding comments from BigPicture, and only including comments after 25 November 2021 00:00:01
And now I am getting the error ...
No signature of method: java.util.Date.parse() is applicable for argument types: (String, String) values: [dd MMM yyyy HH:mm:ss, 25 Nov 2021 00:00:01] Possible solutions: parse(java.lang.String), wait(), clone(), any(), grep(), use(java.lang.Class, groovy.lang.Closure)
... so assuming its something to do with the date check I am doing. The date format piece you directed me to had the following example ...
//Define the date format as per your input def df = "dd.MM.yyyy HH:mm:ss,S" //Parse the date string with above date format def dateTime1 = new Date().parse(df, "13.07.2017 14:03:51,469000000") def dateTime2 = new Date().parse(df, "13.07.2017 14:03:52,469000000") //Compare both date times assert dateTime1 < dateTime2
Instead of defining the format, I opted to put it directly in the parse string, replacing the df variable. If Groovy is like any other language, this should work. So, I missed something obviously. The assert? Although the error seems to be more concerned with the parse than the missing assert.
This is getting complex ... my brain is tired nowHere is the debug, without the parse ...
Comment properties = [created:Wed Aug 18 11:00:00 UTC 2021, roleLevel:null, executor:null, traceType:COMMENT, class:class com.exalate.basic.domain.hubobject.v1.BasicHubComment, updated:Wed Aug 18 11:00:00 UTC 2021, id:501774, idStr:501774, locked:false, groupLevel:null, remoteId:null, updateAuthor:{ @key : 557058:7a06e294-0e9a-4c87-8aac-cd79ff369b03}, restrictSync:false, remoteIdStr:null, internal:false, body:Only phase 1 if using tasks in SKi. Currently managed in SF, author:{ @key : 557058:7a06e294-0e9a-4c87-8aac-cd79ff369b03}]
Saskia sorry to push your button, I know I probably have to log a ticket, but at this point I need someone just to script it for me ... I have spent the entire day on this already.
- Charlie Schonken
Saskia pls can I have help on this
- Francis Martens (Exalate)
Found some time to look into this one.
Following works. Note that if you add ',S' into the pattern - the thing behind the ',' is added to the timestamp. So 469000000 is equivalent to 5 days and someOutgoing sync | Testedimport java.text.SimpleDateFormat // only comments after Jan 12, 2022 def df = "dd.MM.yyyy HH:mm:ss" def limitDate = new SimpleDateFormat(df).parse("12.01.2022 14:03:51") def limitTimeStamp = limitDate.getTime() replica.comments = issue.comments.findAll { comment -> comment.author.displayName != "Joe Soap" && comment.created?.getTime() >= limitTimeStamp }
Give it a try and let me know
- Charlie Schonken
Hi Francis Martens (Exalate) ,
Before I implement, one question.
I currently have the comments configured to only share public comments
replica.comments = issue.comments.findAll { !it.internal }
Will this new script still only share public comments after a certain date, or will it now share ALL comments? It is a risk for me, as the destination is external. Does it need to be edited to still make sure its only public comments?
Do I just add it after the timestamp?
import java.text.SimpleDateFormat // only comments after Jan 12, 2022 def df = "dd.MM.yyyy HH:mm:ss" def limitDate = new SimpleDateFormat(df).parse("12.01.2022 14:03:51") def limitTimeStamp = limitDate.getTime() replica.comments = issue.comments.findAll { comment -> comment.author.displayName != "Joe Soap" && comment.created?.getTime() >= limitTimeStamp && !it.internal }
- Francis Martens (Exalate)
Better to use
... && !comment.internal
Syntactical your suggestion is correct, but less readable
- Charlie Schonken
busy testing ... will advise
Much appreciated Francis Martens (Exalate)
- Francis Martens (Exalate)
You're welcome and thank you for the patience.
Add your comment...
We have a JIRA Cloud to JIRA Cloud connector
We went to exclude syncing comments from a specific user for a specific date
Example: We have comments made by Joe Soap on 24 November 2021 on SystemA
We do not want Joe's comments for that date to sync to SystemB
I know this must be possible via the author comment tag, but no idea how to accomplish this Support