Sprint Sync only when sprint name contains text

Originally asked by Harold Oconitrillo on 27 April 2023 (original question)


I want to write an IF statement to test a text field value … but I don’t want to use equal (==) or not equal (!=) … I want to see if the text field contains a specific piece of text … how do I do that?

For example … I want to sync sprints from a board … but only sprints which names contain the text ‘MDDUS’

def boardIds = ["240"] //Boards which sprints will get synced
if(entityType == "sprint" && boardIds.find{it == sprint.originBoardId}){
    if (sprint.name!="MDDUS") return
    replica.name = sprint.name
    replica.goal = sprint.goal
    replica.state = sprint.state
    replica.startDate = sprint.startDate
    replica.endDate = sprint.endDate
    replica.originBoardId = sprint.originBoardId
}

Answer by Ariel Aguilar on 28 April 2023

Hi there,

If you want to make your script to return whenever the sprint name does not contain “MDDUS”, you can do the following:

if (entityType == "sprint" && boardIds.find { it == sprint.originBoardId }) {
    if (!sprint.name.contains("MDDUS")) return
    replica.name = sprint.name
    replica.goal = sprint.goal
    replica.state = sprint.state
    replica.startDate = sprint.startDate
    replica.endDate = sprint.endDate
    replica.originBoardId = sprint.originBoardId
}

Thanks,

Ariel