BPM to set a UD Date field?

I’m working on a BPM on part duplication. We have a field on the part table for “Date Part Created” so they want it set to the date the part is duplicated. I’ve set BPM data fields and have a test message display the date. So I know the expressions are working to set dates but I can’t get it to update the field.

I’ve tried setting it to All Rows, Updated, Added, etc

For the expression I’ve tried:
resultPartRow.UDField<System.DateTime?>(“udDateCreated_c”)

and

ttPartRow.UDField<System.DateTime?>(“udDateCreated_c”)

Just calling the date via
DateTime.Today
BpmFunc.Now()
BpmFunc.Today()

is this a pre-processing method directive or an in-transaction data directive?

Nathan,

It’s a pre-processing method. It’s initial purpose was to only allow certain users to be able to duplicate parts.

I remember a while back dealing with something similar and we ended up using a pre-processing directive for the condition and to enable a post directive. The post did the actual update.

The way I did this was to pass targetPartNum in the pre-processing to the BPM context data and then use it in the post directive to update the correct part. Probably guessing there is an easier way but fought with this one for a while.

1 Like

Dan, I’ll experiment with that today. Thanks!

Use an In-Transaction Data Directive on the Part Table. Check for an Added Part and set your custom field to Today.

That would work and several other approaches would work but Randy mentioned doing this on duplicate part and not on any part add in general.

Thanks for the suggestions.

I may have to go with Brian’s suggestion, I tried the post-process and it’s still not setting the field. I even tried a text field to see if it was a issue with date-type.

I’ve Added Row, etc but still no go

Here is how it is done if you care to try it.
DuplicatePartBPM.pdf (206.9 KB)

3 Likes

Awesome Dan, I’d never of figured that one out!

How to you set a DateTime UD field back to unset/cleared/blank?
In the DB they are nullable SQL datetimes.
But when trying to set em to NULL to DBNULL or whatever it doesn’t seem to work.
Setting the UD datetime field to another yet unset UD DateTime Field doesn’t work either.
I get “The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value” this in the serverlog, that is in E10.2.500.8

Hi @Philipp_Katscher,
have you tried this function ?

Awesome!!!
What worked was “default(DateTime?)“!
Thank you for that hint!

1 Like