BPM CostAdjustment BO Help

Hi all,

I am trying to create a BPM which will update the average material cost if a user is doing a quantity adjustment and the average material cost is 0. I created a Pre Processing Method Directive to fire before the quantity adjustment happens. First I started out with it just making a message appear and that worked great. Next I wanted to call the CostAdjustment Service to actually update the cost. I am not getting any syntax errors, but when the BPM fires on a quantity adjustment I do.

Code In Question:

Error: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter ‘index’)

I must be missing something here.

What tools can I use to debug this? How do I get more information on what needs passed to the services? This is my first time trying to call a BO from a BPM in custom code. I have been using the developer tools on the browser to see what services are being called and what parameters are being passed through and what the indexes are of the ds.

Thanks for the help!

Looks like when doing a trace it didn’t pick up the BO GetNewCostAdjustment and GetNewCostAdjustmentList. Adding these fixed my problem. I would recommend looking at the REST API Help to find all the service calls relating to what you are trying to do. That is where I found it and figured my indexes weren’t being created.

Some notes for anyone else who is working on anything cost adjustment related. Make sure you repeat GetNewCostAdjustment two times to create both rows. The first row will be the original record for the cost adjustment and the second one will be what the cost adjustment will be.

Here is a snippet of my code that I got working: