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 commented on 26 November 2021
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) commented on 26 November 2021
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
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 commented on 26 November 2021
Hi Francis Martens (Exalate)
Sorry … maybe it’s me.
I have now literally copied your script from above
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 now
Here 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 commented on 18 January 2022
Saskia pls can I have help on this
Francis Martens (Exalate) commented on 03 March 2022
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 some
Outgoing sync | Tested
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
}
Give it a try and let me know
Charlie Schonken commented on 09 March 2022
Hi Francis Martens (Exalate) ,
Before I implement, one question.
I currently have the comments configured to only share public comments
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?