I had a requirement where I have to update a inventdimid whenever creating a new batch/production order in prodbom table . I have wrote the logic in oninserting event handler of prodbom table. I tried to debug a code (attached snapshot)
In the line ProdBom peodbomup =sender as ProdBom, it is not selected a data, value is null. It would be great help if if anyone suggests a solution.
Thanks
CoC (Chain of Command) is an absolutely crucial topic for extensiblity. It's an easier and more powerful way for writing extensions. You define an extension class and override methods. Such a method has the same name and parameters as the method you're extending (such as insert()). You'll use the next keyword to call the base method, and put code before or after this next call to execute code either before or after the standard logic.
You can refer to the current object by this.
You can see all these things in my example above.
You can also easily refer to class variables or form controls by name, you can access protected members, add methods, add class fields and so on.
Please read Class extension - Method wrapping and Chain of Command in F&O documentation.
Actually I'm a newbie, didn't used Coc before.
Are you saying that you think that my code can't be used for a standard table, because you aren't aware of CoC at all? :-o
If so, I have some great news for you...
Thanks and noted the point for update(). But I'm working on standard table and form, I need current instance of the table. How can I achieve that. Sender as table is not selecting any Data.
I don't know what the problem is, but can't you avoid the whole situation by simply using CoC?
By the way, I see you're trying to update a record that hasn't been inserted yet, which would obviously fail. Just set the value and don't call update(); let the system to insert the record.
With CoC, the code will look somehow like this:
void insert() { this.InventDimId = BOM::find(this.BOMId).InventDimId; next insert(); }
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156