Snippets

Adaptavist Post-function to set DatePicker cf with the current date

Created by Joaquin Fernandez
def issueKey = issue.key

// get custom fields
def customFields = get("/rest/api/2/field")
        .asObject(List)
        .body
        .findAll { (it as Map).custom } as List<Map>

def input1CfId = customFields.find { it.name == 'newD' }?.id  // replace newD by your DatePicker cf name


Date today = new Date()

put("/rest/api/2/issue/${issue.key}") 
    // .queryString("overrideScreenSecurity", Boolean.TRUE) 
    .header("Content-Type", "application/json")
    .body([
                fields: [
                        (input1CfId): today.format('yyyy-MM-dd') as String
                ]
        ])
        .asString()

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.