indikad wrote:code attached. Thanks.
Ok - the plugin you supplied hooks into the SaveEnding event of the job, and sets a custom field value and then calls the job save method. I said previously not to call the custom field save method, but instead use the job save method - but what I didn't realise was that you were doing this in a SaveEnding handler.
You should instead be setting your custom field values in the SaveStart event. Add a handler to that instead, and then set your custom field contents there - and don't call the save method at all - that will happen for you.
To understand the sequence of events:
- User clicks the Save toolbar ribbon
- Form controller invokes the form Save method
- Form invokes the business logic save method
- Business logic starts a new SQL transaction if one is not already started
- Business logic raises a SaveStart event
- Business logic issues insert/update/delete to SQL
- Business logic raises a SaveEnding event
- Business logic commits or rollbacks transaction (if it started the transaction)
- Business logic raises a SaveEnd event
In the above flow, your plugin added a handler for the business logic SaveEnding event - so your plugin gets invoked after the updates have taken place. You need to modify your custom field contents before the SQL is issued, so that would be at the SaveStart.
Attached is a modified version of your plugin which works for me. Note that in your code you were checking for the custom field name = "Test Field", but the actual custom field name is "Test field" - string comparisons are case sensitive, so I modified your code to have the correct casing.