Fetching BatchJob by options

#1

I want to fetch by options.id for my type that extends BatchJob. I thought I would be able to do MyBatchJobType.fetch({ filter: Filter.eq('options.id', '1234')}) but this throws the error: Field 'id' does not exist in expression: 'meta.tenantTagId == 1 && ((startsWith(typeIdent, 'BATCHJ:MY_TYPE')) && (contains(options.id, "1234")))' for type 'MyBatchJobType I then switched to MyBatchJobType.fetch({ filter: Filter.contains('options', '1234')}) and this returns all results as expected. Why does options.id not work for fetching?

0 Likes

#2
options: Obj
options for this Batch Job

use generic obj ref so base table won't get overloaded with hundreds of columns

The documentation shows that options is an Obj, which means it can be any sort of Obj. Only Persistable objs have an id field.

0 Likes

#3

@Dylan BatchJob has a field id, so you may want do something like (assuming 1234 is a job id):

MyBatchJobType.fetch({ filter: Filter.eq('id', '1234')})

Can you share a sample of the options you’re using?

Full documentation to BatchJob https://[domain]/api/1/[tenant]/[tag]/documentation/type/BatchJob

0 Likes

#4

In this case my Obj is a persistable type with an id field. Is there something else that would hinder the fetch from working?

0 Likes

#5

The id 1234 is the id of the Obj (Scenario) that I want to fetch by. I have a Scenario.c3typ and a calculatePertinence function that takes a while to run so I start a BatchJob for it. The options field is of type Scenario which a persistable type.

0 Likes

#6

OK so you are overriding options from BatchJob!
Try first renaming your field to something else like scenarios and check if it works.

0 Likes