Hi, so the primary key of the "Customer Bank Account" is ( Customer No. + Code ) . Right now we handle the Code field internally to make sure the field is consistent ( incremental number) . If i try to POST an insert through my API which only contains Customer No. and IBAN , I get the error "Code must have a value in Customer Bank Account .It cannot be zero or empty." Which i understand but that's been already taking care of in the OnBeforeInsert() trigger which is never reached. Is there a better solution than to just pass a redundant code field which we override anyway?
( P.S.: Is there something equal to "Breakpoints on Trigger" in Navision? I don't know want to set the earliest breakpoint possible on an "attach and debug next" session.)
Answers
Are you exposing a page?
Hope these help
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-develop-custom-api
https://www.kauffmann.nl/2020/05/05/deep-insert-with-business-central-apis/
https://www.kauffmann.nl/2021/03/12/extending-standard-apis-1/
Hi @kenyo
You would need to include Code too along with Customer No. and IBAN in your POST request. This will make your code in OnBeforeInsert() execute. You can pass any fixed dummy value for Code in your request, but your logic in OnBeforeInsert() will insert the right 'Code' in Customer Bank Account record.
Yes that's how i eventually handled it but passing dummy values doesn't look like best practice to me. Thanks though!