How to make Sales Order can't be posted when Sell-to Customer No and Bill-to Customer No have the same value

Hi everyone,

Can anyone help me to make my sales order can’t be posted whenever value in “Sell-to customer no” field and “Bill-to customer no” field different ?

I know nav already provided their default system to fill “Bill-to customer no” the same value as “Sell-to customer no” whenever you put a value in there, but i just want to add a control to it.

In Codeunit 80 you can write as follows Below SalesLine.CalculateTCS(SalesHeader); Line of CU 80

IF “Sell-to customer no” <> “Bill-to customer no” THEN

ERROR(‘Your message here’);

But What will happen in those cases where Sell happen to one customer but billing is done to another customer. Check with ur client .

Why not make the Bill-To Customer No = Not Editable or just not editable for certain users.

Setting this property is easier than adding code. Then use it for a few weeks and then you’ll see where/if any problems occur with order processing.

Then what’s set on the customer card will stay.

I completely agree with Savatage. It is better to see how making the field “uneditable” pans out rather than using a code.

Like the rest of you, I do tend to favor the minimalist approach. But in this case, I don’t think that changing the editable property on the form control for “Bill-to Customer No.” is the best approach.

The first issue that I see is that it will take more time to implement than you might think. If you’re making the change on the Sales Order form, you’d probably also want to make the change on Sales Quote, Sales Invoice and Sales Cr. Memo. You’d also need to find any forms in the custom range that might need to be updated. And, from now on, you’ll have to remember to make this mod on any new forms that involve the Sales Header.

The second possible problem would be that, aside from the forms you’ve modified, there are too many ways to change the “Bill-to Customer No.” value without applying the new rule. The client could add new or modify existing forms, dataports, reports, codeunits etc. that may inadvertently bypass this new rule. I’m not saying that this will certainly happen, nor that the user would do something like this intentionally. But, it’s possible. And as much as I like concise solutions, I dislike vulnerable solutions even more.

And finally, this approach denies that there might ever be a legitimate reason for having the “Bill-to Customer No.” value be different than the “Sell-to Customer No.” value.

To increase the certainty that the rule would be applied consistently, I would put one line of code either very early (maybe even as the first line) in the OnRun trigger of codeunit 80 Sales-Post, or in the OnInsert and OnModify triggers of table 36 Sales Header. That line would be:

TESTFIELD(“Bill-to Customer No.”, “Sell-to Customer No.”);

Of course, if you did need to allow for the possibility that the values might legitimately be different, then you’d need to add more code at that point.

You could argue that this is just a question of style, but, in my opinion, putting the new code in either the table or the posting codeunit would be a one-time change that probably would not come back to cause me problems in the future. I don’t think the same could be said for putting the new code in the Sales Order form.

George, Amol, Akash, thanks for your reply. I couldn’t done it without you guys.