Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hello,

I am trying to use the BulkUpdateAgent to clear a specific UD field on the project entity, only the batch task is immediately set to state 4 (Succeeded) without it actually doing anything.

Example code:

string FullNameFieldProgId = "SuperOffice:7";

using (SuperOffice.CRM.Services.BulkUpdateAgent BulkUpdateAgent = new SuperOffice.CRM.Services.BulkUpdateAgent())
{
	SuperOffice.CRM.Services.FieldValueInfo UpdateField = 
		BulkUpdateAgent.GetAvailableFields(SuperOffice.CRM.Data.ProjectTableInfo.DictionaryTableName).FirstOrDefault(f => f.Key == FullNameFieldProgId);

	UpdateField.IsActive = true;
	UpdateField.CurrentOperationType = SuperOffice.CRM.BulkUpdate.BulkUpdateSystem.OperationTypes.Clear;

	string Ids = string.Join(",", new List<int> { 24473, 24474 });

	int BatchTaskId = BulkUpdateAgent.ExecuteByEntityIds(new SuperOffice.CRM.Services.FieldValueInfo[] { UpdateField }, 
						 SuperOffice.CRM.Data.ProjectTableInfo.DictionaryTableName, "", Ids);
}

In reality the ids string has about ~15 000 project id's in it.

 

SuperOffice Version: 8.4 R4, services84.

 

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hi David,
not my domain, but I will risk falling flat on my face - again - it doesn't hirt anymore :-)
My guess is you need to dig into the Batch system.
What is the point of returning a batchtaskinfoid? This is not a "synchronous" system.
I think you need to go into a poling loop, calling the state of the batch job and wait for it to terminate.
You are effectively going out of scope and killing the job.

I am sure Tony will clarify this in due time :-)
/conrad

Just curious: why not make a selection and use the GUI?

 

Af: Conrad Weyns 21. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Or just use a SearchEngine and call its .update() method?

Af: Frode Lillerud 21. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hello Conrad & Frode, My guess is you need to dig into the Batch system.
What is the point of returning a batchtaskinfoid? This is not a "synchronous" system.
I think you need to go into a poling loop, calling the state of the batch job and wait for it to terminate.
You are effectively going out of scope and killing the job.
The batch task id is purely there for debugging purposes, so that I can look up the BatchTask inside the database using the ID.

Related to the "state" of the job, when calling the BulkUpdate system using the Web Services, what happens (so far as I know) is that a batch task is created and inserted into database. Which is then picked up either by the Application pool process, or the Batch task service when enabled. (RunTasksInProcess = false). The Bulk Update job is not being run on client side.

The polling / state calling way is indeed the way we have done it in the past when programming on NetServer Core level.

For some reason the bulk update engine immediately marks the job as succeeded, without any error being logging.

Just curious: why not make a selection and use the GUI

Or just use a SearchEngine and call its .update() method?

Some context: this snippet is part of a large import system that we are rewritting from NetServer Core to Web Services. Neither the GUI nor SearchEngine is available. (And update() does a direct SQL query which skips updating TTL, FreeText etc.)

 

 

Af: David Hollegien 21. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Also trying to retrieve the result of the job gives no result:

int BatchTaskId = _BulkUpdateAgent.ExecuteByEntityIds(new SuperOffice.CRM.Services.FieldValueInfo[] { UpdateField }, SuperOffice.CRM.Data.ProjectTableInfo.DictionaryTableName, "", sIds);

// null
string[] TestResult = _BulkUpdateAgent.GetJobResultsFromStorageAsJson();

// empty
string TestResult2 = _BulkUpdateAgent.GetJobResultAsJsonFromBinaryObjectId(SuperOffice.CRM.Data.ProjectTableInfo.DictionaryTableName, BatchTaskId);

using (SuperOffice.CRM.Services.BatchAgent BatchAgent = new SuperOffice.CRM.Services.BatchAgent())
{
	// ParameterObject is filled with context, entityIds and tableName
	// result is empty
    SuperOffice.CRM.Services.BatchTaskInfo BatchTaskInfo = BatchAgent.GetBatchTaskInfo(BatchTaskId);
}
Af: David Hollegien 21. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Just in case..

What is the field type of your "SuperOffice:7" ?
Need to make sure that the Clear operation is supported. Verify this in the GUI if you are not sure.
/conrad

Af: Conrad Weyns 22. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hello Conrad,

It's an short text UD field on the project entity, Just tried to configure the clear option in the GUI (WEB), it is possible, but it also doesn't do anything. (No records changed).

Workaround I found is using the Set operation instead of clear:

UpdateField.CurrentOperationType = SuperOffice.CRM.BulkUpdate.BulkUpdateSystem.OperationTypes.Set;

UpdateField.Values = new[] { "" };

 

 

Af: David Hollegien 22. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hi David,

Ok thanks.
Then we are looking at a bug for a udef field type in the bulkupdate system.
I will verify this some time today.
/conrad

 

Using our latest Win client, I just tried a selection of projects.
Used Clear operation on a udef field of type shortText.

Works fine.

Af: Conrad Weyns 22. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

I'm unable to successfully reproduce the observed behavior.. With and without a unique context, it works as expected.

What service endpoint version?

Af: Tony Yates 22. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

RunTasksInProcess = false
BatchTaskJob immediately finishing without changes

i.o.w. after you executed your code, you are seeing a new batchtask row and new FieldValueStorage.SuperOffice:7 (conseptualType) binaryobject row in the db.
Then, after whatever is responsible for executing these, you are seeing the batchtask row disappear without any expected changes to your collection of projects.

I am able to make your code work, in process, in its own session.
But I still have to wait for it as a thread is spawn else the session pulls everything down when going out of scope.

Are we missing something?
My interest in this is the core netserver bulkupdate system, as I am responsible for this.
But a.f.a. all the paraphernalia around services, batchtask, application pool and what not, I am at a loss - sorry!


/conrad

Af: Conrad Weyns 23. nov 2018

RE: BulkUpdateAgent issue, BatchTaskJob immediately finishing without changes

Hello Tony & Conrad,

Strangest thing, it is working correctly now... Only thing 'changed' is that the Test environment has been rebooted this night.

Also added a unique context to the ExecuteByEntityIds call, but removing that again doesn't change that it works now.

Strange....

(Using service endpoint services84)

Af: David Hollegien 23. nov 2018