Options

[BC] Problem with insert into "Customer Bank Account" through custom API

kenyokenyo Member Posts: 40
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.)

Best Answer

  • Options
    manjumanju Member Posts: 19
    Answer ✓
    kenyo wrote: »
    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.)

    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.

Answers

  • Options
    manjumanju Member Posts: 19
    Answer ✓
    kenyo wrote: »
    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.)

    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.
  • Options
    kenyokenyo Member Posts: 40
    manju wrote: »
    kenyo wrote: »
    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.)

    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!
Sign In or Register to comment.