Find a date field by name. Returns field_id.
(project_id: str, field_name: str)
| 200 | |
| 201 | |
| 202 | def get_date_field(project_id: str, field_name: str) -> str: |
| 203 | """Find a date field by name. Returns field_id.""" |
| 204 | query = """ |
| 205 | query($projectId: ID!) { |
| 206 | node(id: $projectId) { |
| 207 | ... on ProjectV2 { |
| 208 | fields(first: 50) { |
| 209 | nodes { |
| 210 | ... on ProjectV2Field { |
| 211 | id |
| 212 | name |
| 213 | dataType |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 | """ |
| 221 | data = graphql(query, {"projectId": project_id}) |
| 222 | fields: list[dict[str, Any]] = data["data"]["node"]["fields"]["nodes"] |
| 223 | |
| 224 | for field in fields: |
| 225 | if field.get("name") == field_name and field.get("dataType") == "DATE": |
| 226 | return field["id"] |
| 227 | |
| 228 | raise SystemExit(f"Date field '{field_name}' not found in project") |
| 229 | |
| 230 | |
| 231 | def update_single_select( |