Setting up a UD database field value as the creator of the record in RMA using BPM

Dear Epicor commnity members,

I am trying to set the value of a UD column in a UD database table when a record is created and set its value to the creator of the record. In simple terms, I want to know who has created the RMA record.
I have created the UD field and UD textbox is bound to it as well. I wanted to do this through form customization but there are no form events available apparently that fetch creation of a record:

That leaves me with only one option and that is BPM and more specifically Method Data Directive . So I tried this:

As you can see I chose the GetNewRMAHead and Post-Processing.
Also this is the structure:
image

I used a message to see if the BPM is running which indeed it runs after clicking on new symbol on RMA page:

This is the code in the custom code block:

 foreach(var rmarowtt in (from rowiter in ttRMAHead select rowiter))
 {
     foreach(var rmarowdb in (from rmarowdb in Db.RMAHead select rmarowdb))
     {
         if(rmarowtt.RMANum == rmarowdb.RMANum)
         {
             string value = callContextClient.CurrentUserId.ToString();
             rmarowdb.RMAOwner_c = value;
         }
     }
 }

The Record gets created without any errors by BPM but the field does not get set.
I searched a little bit and found out that apparently instead of a normal C# syntax for setting the value, I should use a special method with this format:

rmarowdb.SetUDField<System.String>("RMAOwner_c", value);

This did not work either.

So I tested it over and over through Data Directive as well. I used this:

I realized that when record is created, the UD field gets a default value:

So as soon as the record is created, my BPM sets the value but then the default value gets assigns apparently and over-writes the BPM value, the second time I changed the customer, I checked the database and the value was shown correctly this time.

That is all that I have managed to achieve so far. I understand this is not a difficult task for many of you so I appreciate any help I can get here.

Regards,

1 Like

The BPM can be much simpler. Just use the Set Field widget. The User ID is in the Call Context Client table.

Hi @Jason_Woods
I need to specify a row for this to work:
ROW…SetUDField<System.String>(“RMAOwner_c”, value);

How should I access that row? Maybe I am missing something here?

No Code required. Use the “Set Field” widget.

1 Like

Hi @Jason_Woods
Wow I am not sure how I missed that. You are a legend!