"I am trying to create a new BP record, but when I click add it comes up with an error regarding the BP code?"


To fix this, take the last BP code of the same type (e.g. customer, supplier or lead) and increment this number by 1 and manually type this in to the field 'BP Code'



The reason this error happens is because there is a formatted search in place which will automatically assign a new BP code when a new BP record is being created; this is so that the user doesn't have to manually choose and type in a number when creating a new record. (for more information on Formatted Searches please click here )

The error occurs when a BP record has previously been created and the user has generated a new code using the formatted search (magnifying glass) but then subsequently changes the BP type AFTER this code has been generated. 

This is because the system defaults to BP type 'Customer' and therefore the code is generated with a pre-fix of '2'. However if the type is then subsequently changed to either Supplier (pref-fix 5) or Lead (prefix 8) then the SQL code in place on the formatted search gets broken because it does not know which previous code it should refer to the next time one is being generated.

This is why looking at the last code used and incrementing by 1 fixes the problem; in effect it "resets" the formatted search.

This specific formatted search is based on the type of business partner to be created and therefore the BP number field is dependant on the BP type selected at the time of creation.

The formatted search uses the following logic based on the BP type to assign BP codes:
  • Customer = code prefixed with 2****, the system then looks at what the last BP code was which is prefixed by a 2 and increments this number by 1 to make the new BP code
  • Supplier = code prefixed with '5****'the system then looks at what the last BP code was which begins with a 5 and increments this number by 1 to make the new BP code
  • Lead = code prefixed with '8****' the system then looks at what the last BP code was which begins with 8 and increments this number by 1 to make the new BP code

The specific SQL code for the BP Numbering Formatted Search is shown below:

SELECT  CASE N'L'
WHEN 'S' THEN (SELECT MAX(T1.Cardcode)+1 from OCRD T1 WHERE T1.Cardtype = 'S' AND LEFT(T1.CardCode,1) = '5')
WHEN 'C' THEN (SELECT MAX(T1.Cardcode)+1 from OCRD T1 WHERE T1.Cardtype = 'C' AND LEFT(T1.CardCode,1) = '2')
ELSE 
(SELECT MAX(T1.Cardcode)+1 from OCRD T1 WHERE T1.Cardtype = 'L' AND LEFT(T1.CardCode,1) = '8')
END



Copyright © Published April 2013, Author: Laura Haywood-Jeffery, Ownership: Laura Haywood-Jeffery


(1)   Ownership of copyright

 The author of this document owns the copyright in:

 (a)  this website; and

 (b)  the material on this website (including, without limitation, the text, audio material, video material and audio-visual material on this website).

 (2)   Credit

 This document was created using Freshdesk.com

 (3)   Copyright licence

 We grant to you an exclusive and revocable licence to:

 (a)  view this website on a computer or mobile device via a web browser; the author reserves the right to revoke the material contained within at any time

 (b)  print pages from this website for your own [personal and non-commercial] use.

 

We do not grant you any other rights in relation to this website or the material on this website. In other words, all other rights are reserved.

 For the avoidance of doubt, you must not adapt, edit, change, transform, publish, republish, distribute, redistribute, broadcast, rebroadcast, or show or play in public this website or the material on this website (in any form or media) without the author/owners prior written permission. 

 (4)   Data mining

 The automated and/or systematic collection of data from this website is prohibited.

(5)   Permissions

 You may request permission to use the copyright materials on this website by writing to lhaywoodjeffery@gmail.com

(6)   Enforcement of copyright 

We take the protection of our copyright very seriously.

 If we discover that you have used our copyright materials in contravention of the licence above, we may bring legal proceedings against you, seeking monetary damages and/or an injunction to stop you using those materials. You could also be ordered to pay legal costs.

 If you become aware of any use of our copyright materials that contravenes or may contravene the licence above, please report this by email to lhaywoodjeffery@gmail.com

 (7)   Infringing material

 If you become aware of any material on our website that you believe infringes your or any other person's copyright, please report this by email to lhaywoodjeffery@gmail.com