Find datasets with custom field values

FindDatasetsWithCustomFieldValues.py

from LOGS import LOGS
from LOGS.Entities import DatasetRequestParameter

# Connect to LOGS
logs = LOGS()

# Retrieve all datasets that match specific values in a custom field
# to identify the correct custom Field ID, navigate to More -> Custom Fields and enable the Custom Field Id
# alternativly you can load the ID directly via LOGS Python using the name of the csutom field with:
# logs.customFields(CustomFieldRequestParameter(names=["NameOfField"]))[0].id

results = logs.datasets(
    DatasetRequestParameter(customTypeIds=[1],
                            customFieldSearchExpression="{5} == 'Example'")
)
# Alternative examples for Search Expressions:
# customFieldSearchExpression="{10} != null AND {20} == null" <-- Field with ID 10 not empty AND field with ID 20 empty
# customFieldSearchExpression="{11} == 'NMR' AND {21} == 'zg'" <-- Field with ID 11 equals NMR and field with ID 21 equals zg

# Print the results
print(f'Found {results.count} datasets of specified Custom Type (ID 1) contain the text "Example" in Custom Field with ID 5:')
print("-" * 70)

for d in results:
    print(f"Dataset: {d.id} - {d.name}")