JobHead.CreateDate

I want to update a UD field that captures the time a job is created. To do that I want to update that UD field when the JobHead.createdate gets populated.

Can I get the createdate in the Erp.BO.JobEntry.GetNewJobHead method directive? Any help with sample code would be appreciated.

An in-transaction data directive on JobHead may be the best approach here since I believe a lot of methods can ultimately create jobs. I’m not sure how your field is storing the time, so I’ll assume a field JobHead.CreateDateTime_c that stores the date & time of creation.

You can start with a Condition for “There is at least one added row in the ttJobHead table”.

If true, go to a Set Field widget to “Set the CreateDateTime_c field of the added row to the specified expression”. In the specified expression, I think DateTime.Now should do the trick.

You can achieve all of the above in one Custom Code block as well, if you prefer that approach:

foreach (var ttJobHead_row in ttJobHead.Where(x => x.RowMod == "A"))
{
    ttJobHead_row.SetUDField<System.DateTime>("CreateDateTime_c", DateTime.Now);
}

Open to being corrected by some more expert BPM folks here, but that’s how I’ve done it before. Make sure to test this and all development in a PILOT environment before deploying the PROD.

1 Like

maybe in post processing you can, but you might want a data directive instead, because that would tell you that the field has actaully hit the database.

I think that GetNewJobHead does not necessarily conclude that a job was “created”.

1 Like

Nice.

I was going to do it in a UD datetime field, but they want just time. I was going to create a string UD field and do code to capture the datetime then strip out the date and only store the time in the UD field.

Thank you!

1 Like