Method Directive to Populate UD Field

I have a UD field in Case Entry that I want to populate with the ship date from ShipHead.

I’m trying to do that with a pre-processing directive on erp.bo.helpdesk.update.

When I go into Case Entry and make any updates the start date is not getting populated like I want. I may be totally off base with the way I’m trying to do this. Any help would be appreciated.

My first thought would be to check and make sure that your query is actually returning rows. Can you share the join criteria between the two tables?

In your query, I think you want to be using ds.HDCase instead of ERP.HDCase. I’d also add a condition to the BPM or it will fire for every update.

here is the join between the tables.

Yeah this is a better answer than mine. But they’re still mapping the field to the actual ds table, I would think it would still update the field with a wrong answer then?

I think that’s good, try changing your ERP.HDCase to the ds.HDCase table with the same join and see if it sets then.

I changed it to ds.hdcase with the same joins and added a condition statement.

The condition is if the ud field is null, then fire.
{AC477340-0C63-435F-9920-DC1D5A0F688E}

Now when I do a change on a case and hit save I get this error.
{FC90CC2E-9A8B-4B79-B0AA-DD78CB64BBB9}

My next step troubleshooting that would be using the dev tools and Ctrl+Shift+V after I’d made the change but before hitting save to verify the HDCase dataview had changes and the change wasn’t going to one of the other dataviews.

1 Like

I feel like the general consensus is not to use Data Directives, but I would use an In-Transaction Data Directive here. You just have to make sure you’re updating the ‘Update’ row (RowMod == “U”). I don’t think it’s possible to not have rows in a data directive, unlike what’s happening in your error above.

break your bpm down and add in a few messages to test/show data to prove that everything before it is working.

I put a message in and it looks like it doesn’t like me calling dsHDCase in the helpdesk.update in the method directive. But when I debug it is showing that it’s using dsHDCase

Is it possible that it’s just not filling out the dsHDcase at the point I’m trying to do the logic in the HelpDesk update?

Yes it is possible, easiest way sometimes is as I mentioned, stick a few messages in to show the data.

I haven’t had any success getting “Fill Table by Query” to work within a Method Directive. However, I’m open to corrections if anyone has managed to make it work.

Additionally, ds.HDCase does not retain UD fields in the update method. I verified this by checking under custom code maybe that is why Fill Table by Query doesn’t seem to be working under method?

That being said, you might want to try what @CaudilC suggested—moving the logic to a Data Directive. If that doesn’t work, custom code should be a reliable alternative. I tested this approach within HDCase In-Trans Data Directive, and it appears to be working as expected.

var y = ttHDCase
    .FirstOrDefault(r => r.RowMod == "A" || r.RowMod == "U");

if (y.yourfield_c!= null)
{
    var z = Db.ShipHead
        .FirstOrDefault(s => s.Company == y.Company && s.PackNum == y.PackNum);

    if (z != null)
    {
        y.yourfield_c = z.ShipDate;
    }
}

I’m getting this error.

1 Like

Try using

y["ShipDate_c"]

instead of y.ShipDate_c

2 Likes

That worked. Yay! Thanks!

2 Likes