I am currently importing data into two boards to simulate a parent/child relationship. The two boards share a value companyName that will link them. I final part of the code I am pasting now works. However, I want to replace one of the hardcoded IDs with a variable. I’ve tried a number of ways without any success.
Query 1, not shown retrieves a JSON with the item ID, item name (company) from the parent board
Query 2, not shown retrieves a JSON with item ID, item name, company name from the child board
The loop below takes a single item from Q2, calls a function to find the matching company from Q1, then calls API to connect_boards.
for allItems2 in itemLevelData2:
singleItem2 = allItems2[‘items’]
# Loop for individual item detail
for itemDetail2 in singleItem2:
#Retrieve the entry ID
itemID2 = int(itemDetail2[‘id’])
columnValues = itemDetail2[‘column_values’]
#print(columnValues)
for company in columnValues:
companyName2 = company[‘text’]
if (search_company(companyName2) != None):
accountRowID = search_company(companyName2)
vars3 = {
‘boardID’: 3030320934,
‘itemID’ : itemID2,
‘myColVals’ : json.dumps({
‘connect_boards’ : {‘item_ids’ : [3028979985]}}) #Want to use accountRowID here
}
queryUpdateRow = ’ mutation ($boardID: Int!, $itemID: Int!, $myColVals: JSON!) {change_multiple_column_values(board_id:$boardID, item_id:$itemID, column_values:$myColVals) {id}}’
data = {‘query’: queryUpdateRow, ‘variables’: vars3}
r = requests.post(url=apiUrl, json=data, headers=headers) # make request
else:
print(“No Match”)
I want to use a variable in vars3 for the connect_boards line.
Any recommendations?
Thanks
Bruce