I am using Python to create bulk entries in a board to track required trainings. I would like to add information and a URL to the training as the first comment for the item. Can I do this in the initial mutation? Or do I need to capture the item ID and add the comment in another loop?
Thanks
Bruce
— Current script, no adding an update ----
trainingTitle = ‘Do this activity’
trainingDueDate = ‘2022-07-31’
teamsID = ### # Workflow Practice Team
teamsID = ### # Python Test Team
‘’’
Script begins
‘’’
updates_query = ‘{teams (ids:’ + str(teamsID) +‘) {users {id }}}’
data = {‘query’: updates_query}
response = requests.post(url=apiUrl, json=data, headers=headers) # make request
allData = response.json()
Traverse the JSON file
boardLevelData = allData[‘data’]
teamLevelData = boardLevelData[‘teams’]
Loop to navigate through the list
for allItems in teamLevelData:
singleItem = allItems[‘users’]
count = 0
# Loop for individual item detail
for userDetail in singleItem:
userID = userDetail[‘id’]
# Add training entry for each person
vars = {
‘myItemName’ : trainingTitle,
‘columnVals’ : json.dumps({
‘date4’ : {‘date’ : trainingDueDate},
‘status’ : {‘label’ : ‘New’},
‘person’: {‘personsAndTeams’ :[ {‘id’ : userID, ‘kind’ : ‘person’}]}
})}
query1 = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:1672697065, item_name:$myItemName, column_values:$columnVals) { id } }'
data = {'query' : query1, 'variables' : vars}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
jsondata = r.json()
print(jsondata)