Hi to all the community,
After struggling a little by my own & my son (studying CS @UoT Canada) and some support from the Tadabase chat, I was able to do mostly of my app, a multi-company Project Management tool in Tadabase. There’s only one missing item that I will go deeper afterward.
The idea is to have something like an app template to be used in many other apps. The app works at least with 4 tables:
- Projects (subprojects in my case because I have different project categories in project parent table)
- Tasks (the tasks to be done) including dependencies between tasks for the logical order to do the project
- Template (a template of fixed tasks including dependencies that everytime I create a project for a company, copies all the tasks and its dependencies only for this company)
- Companies, at least the name
The tricky point here is to assign the right dependencies to the tasks considering that the template tasks have different record ID than the tasks itself, and we cannot assign dependencies in a first round because maybe the record still is not created, so it’s done in second round.
As you can see in images “Field logic”, the fields are quite normal.
Now the better is coming… in order to do the creation with just a few info (Company, project name), after struggling with pipes, tasks, rules, etc. without an effective result, we created a simple 2-step zap in Zapier as you in the images: triggering with the new subproject to get the record ID and executing a python code to create the new tasks with dependencies from the template/company pair.
The process works instantly and et voilà! As you can see in the pictures, obviously every task (template & tasks) has
- start date (from subproject current date crearion)
- duration
- end date (equation from the two above)
And as the dependencies mean, after this process, ALL the tasks start at the same date. However, to do a workaround we can set: - a new field “Dependent Date”
- a edit rule in the tasks table, setting the Start Date as of the Dependent Date
- a new Task automation (demand), of Tasks table, update the connected records (task dependent on), setting the Dependent date as of the record value of End date
We can then create a page to see the subprojects, see the subproject details of record, see the tasks related to this record and set a task component calling the previous automation. So if we click the new button, all the dates will be set accordingly.
HOWEVER, and finally that’s my concern, this only works well if dependency is UNIQUE. We tried with a template where some tasks have multiple dependencies and Tadabase mixes dates and the output is mixed. Also the option of a rollup field with dependencies and calculating the date max value would be the easiest way to do that, but there’s a known bug and it’s not working…
So, in the end, happy with the work and glad to share to the community, but a bitter flavor for multiple dependencies and hope Tadabase could fix that.
I’m copying the script right below. Enjoy!
Andrés
import requests
APP_ID = input_data[“appId”]
APP_KEY = input_data[“apiKey”]
APP_SECRET = input_data[“apiSecret”]
get subproject record data
SUBPROJECT_TABLE = input_data[“subProjectTable”]
SUBPROJECT_ID = input_data[“subProjectId”]
url = f"https://api.tadabase.io/api/v1/data-tables/{SUBPROJECT_TABLE}/records/{SUBPROJECT_ID}"
payload={}
headers = {
‘X-Tadabase-App-id’: APP_ID,
‘X-Tadabase-App-Key’: APP_KEY,
‘X-Tadabase-App-Secret’: APP_SECRET
}
response = requests.request(“GET”, url, headers=headers, data=payload)
COMPANY_FIELD_SUBPROJECT = input_data[“companySubproject”]
subproject_company_id = response.json().get(“item”, None).get(COMPANY_FIELD_SUBPROJECT, None)[0]
subproject_id = response.json().get(“item”, None).get(“id”, None)
get data from template associated to the company
tableId = input_data[“templateTable”]
url = f"https://api.tadabase.io/api/v1/data-tables/{tableId}/records"
payload={}
headers = {
‘X-Tadabase-App-id’: APP_ID,
‘X-Tadabase-App-Key’: APP_KEY,
‘X-Tadabase-App-Secret’: APP_SECRET
}
response = requests.request(“GET”, url, headers=headers, data=payload)
COMPANY_FIELD_TEMPLATE = input_data[“companyTemplate”]
all_records = response.json().get(“items”, None)
relevant_records = [x for x in all_records if x[COMPANY_FIELD_TEMPLATE][0] == subproject_company_id]
sorted_relevant_records = sorted(relevant_records, key=lambda x: x[input_data[“orderTemplate”]], reverse=True)
create new records
TASKS_TABLE_ID = input_data[“taskTable”]
url = f"https://api.tadabase.io/api/v1/data-tables/{TASKS_TABLE_ID}/records"
DEPENDENT_FIELD_TEMPLATE = input_data[“dependentOrderTemplate”]
records_created =
for record in relevant_records:
task_ids =
for dependent in record[DEPENDENT_FIELD_TEMPLATE]:
for t in all_records:
if t.get(“id”, None) == dependent:
t_name = t.get(input_data[“taskTemplate”])
task_ids.extend([r.get(“recordId”) for r in records_created if r.get(input_data[“taskTasks”]) == t_name])
print(task_ids)
payload={
input_data[“taskTasks”]: record.get(input_data[“taskTemplate”], “”),
input_data[“subprojectTasks”]: subproject_id,
input_data[“dependentTasks”]: “,”.join(task_ids)
}
files=
headers = {
‘X-Tadabase-App-id’: APP_ID,
‘X-Tadabase-App-Key’: APP_KEY,
‘X-Tadabase-App-Secret’: APP_SECRET
}
response = requests.request(“POST”, url, headers=headers, data=payload, files=files)
if (response.json().get(‘type’, ‘’) == “success”):
new_record_id = response.json().get(‘recordId’, ‘’)
temp = {‘recordId’: new_record_id}
temp.update(payload)
records_created.append(temp)