Consider below setup.
You want to push values from an activity to all the activities in a project. The example below assumes that all the activities in the project is of the same template and same version.
How this works :
- You have a main activity(regular activity) but we call it main just to differentiate between the activity from where the data will be pushed.
- The main script can be of a different template than the other activities. You can mix and match templates, but for simplicity, I'll use a single template to refer and push data.
- You fill or update data in the master activity which you want to push to all the other activities
- You run the script. And the script will contain logic to push the data to other activities by copying the data from main.
- Go to other activities and see the values reflected.
Example :
In the example below, I will just push the Test Asset data of main activity to other activities.
import uuid
from kes.client import Client, Config
from kes.project import Activity
from generated import test_asset_table_def, TestAssetRow
config = Config(
kes_service_address='kes-table-service-training.delightfuldesert-b9ce0345.westeurope.azurecontainerapps.io:443',
access_token='dQFiLQzwV3')
client = Client(config)
activity_id = uuid.UUID('86476067-2ba4-42ae-b8a6-5f6d6573d73c')
activity = client.open_activity_by_id(activity_id=activity_id)
table = activity.build_table(test_asset_table_def)
table.load()
print(table[0].decimal_test_property)
def push_data(activity: Activity):
print(activity.id)
print(activity.description)
if activity.id == uuid.UUID('86476067-2ba4-42ae-b8a6-5f6d6573d73c'):
return
push_table = activity.build_table(test_asset_table_def)
push_table.load()
if len(push_table) > 0:
push_table.clear()
row = TestAssetRow(
single_select_test_property=table[0].single_select_test_property,
multi_select_test_property=table[0].multi_select_test_property,
string_test_property=table[0].string_test_property,
decimal_test_property=table[0].decimal_test_property
)
ref = push_table.append_row(row)
config1 = Config(
kes_service_address='kes-table-service-training.delightfuldesert-b9ce0345.westeurope.azurecontainerapps.io:443',
access_token='dQFiLQzwV3')
client1 = Client(config)
project = client1.open_project_by_id(uuid.UUID('dacd7de5-9c4c-485b-94b0-416239b084f6'))
for activity in project.activities:
push_data(activity)