Question

event Handler

Hi;

I generate an event handler before insert I need to generate sequence number

I did it as it is described in academy

https://academy.bpmonline.com/documents/technic-sdk/7-12/how-add-auto-n…

in second part according server side and it has worked fine when i add the record by add new record process element.

When I create the code adding this record by insert class this event stop working

no errors in browser simply not fill the number

as well as filling createdbyId automatic. I must put it manually.

I will be appreciated for help

Regards

Tomek

Like 0

Like

3 comments

Dear Tomasz,

You are right. Using Insert class doesn't fire any business processes. It connected to the fact that Insert class works directly with database not with entity. We recommend using this class only if perfomance is high priority. It much faster than EntitySchemaQuery class, because the Insert, Update, Delete classes skip all events and rights check. If you want to fire your business process, use EntitySchemaQuery:

var entitySchemaManager = UserConnection.EntitySchemaManager;

var entitySchema = entitySchemaManager.GetInstanceByName("Contact");

Entity schemeObject = entitySchema.CreateEntity(UserConnection);

schemeObject.SetDefColumnValues(); // don't forget call this method every time

schemeObject.SetColumnValue("Name", "Daniel Redkliff");

bool successfullySaved = schemeObject.Save();

Peter Vdovukhin,

 Thanks Peter

 

Peter Vdovukhin,

 

EntitySchemaQuery is also not triggering any event. I am using the update query using EntitySchemaQuery.

My code:

var entitySchemaManager = userConnection.EntitySchemaManager;
var entitySchema = entitySchemaManager.GetInstanceByName("Contact");
Entity schemeObject = entitySchema.CreateEntity(userConnection);
if (schemeObject.FetchFromDB(recordId))
{
    schemeObject.SetColumnValue("Reason", Column.Parameter(reason));
    if (status.ToLower() == "completed")
        schemeObject.SetColumnValue("CompletedOn", Column.Parameter(statusDate));
    schemeObject.Save();
}

 

Show all comments