There's a need to give a default value to "Sell-to Customer No." field on Quotes form. As I didn't want to save it to the Sales Header record, I created a new variable SellToCustNo and gave it my desired default value.
Now, I'd like to validate "Sell-to Customer No." when I leave the the SellToCustNo field. I wrote the code to the onDeactivate trigger
SellToCustNo - OnDeactivate()
IF SellToCustNo <> "Sell-to Customer No." THEN
BEGIN
VALIDATE("Sell-to Customer No.",SellToCustNo);
END;
... the validation stops on DocDim.LOCKTABLE; with the error "you cannot make any changes in the database until a transaction has been started"
...is there any chance to make it work? :-k
0
Comments
Remember to do this only IF the document type is Quote and the field is blank.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
if you say yes, the default value is filled and validated - if you say no - it will let you enter a different number
http://www.BiloBeauty.com
http://www.autismspeaks.org
Do you know what is wrong with the OnDeactivate() trigger, that I can't use it?
Add a command button
Is this what you mean by adding a button?
ps : whats the obession with the deactivate trigger? :-k
http://www.BiloBeauty.com
http://www.autismspeaks.org
this is how I would do it.
1)Create A new field in the sales setup table called "Quote Default Cust No" type code size 20.
2)add it to my sales setup form and fill it in with a value.
3) go to the sales header table and add on the Sell-to Customer No. - OnValidate() trigger (the end)
Now this lets you ENTER a customer number on the quote form. If it matches the default number then you just go on about your business.
If the number entered is different it will ask you if you want to use the default. if you say no it will use the number you entered. if you say yes the cust no is changed to the default - which is set in the sales setup table. ( I add it to the setup table so the field is accessible for changes in the future without the need for code changes and hardcoding)
Raise the fist of the metal child! AHH!
http://www.BiloBeauty.com
http://www.autismspeaks.org
Adding it to the form would be safer solution.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Note if you do use the method of creating a deault no in the setup tabel don't forget to change the table relation property of the field to "Customer"
that way your lookup works nice & neatly.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Yes, that's it
The idea is to force field validation when I move from the field, but it seems to be impossible. Let's say that I would like to make my own lookup code
... when I puch lookup, select a customer and push OK, it will enter the value in SellToCustNo. So far it works like a standard, because it doesn't validate the field yet (it's commented out). Now when I move away from SellToCustNo field, it should start validate, but that doesn't happen and there's no way to make it happen.
What if I want to make an automated import in Sales Header table later on? Then it would ask to enter my default value in every record. To prevent this, I should change the code:
...I still had to use my custom field SellToCustNo in the form to SetHideValidationDialog TRUE.
Thank you for your advises!
There are many ways of handling this. For example we have many ways of entering orders..
Manually, Dataport, EDI, XMLport, Internet, etc.
We've simply created a option field that "marks" each order as one or the other.
You could use something like this and add it to the code to bypass certain critera or only have it fire when "Entry Type" = Manual.
or Perhaps, using the setup table again create a "Use Quote Default" boolean on the setup table.
then simply change the code to
If "Use Quote Default" then begin... to wrap the code.
On the dataport to import orders, the first line would be to get the current value of"Use Quote Default" Save the value in a variable. Clear the "Use Quote Default" boolean. fill the dtaport fields. restore the variable back to the "use Quote Default"
IN other words if you want that code not to effect imported orders.
->i was thinking clear it at the start of the dataport
->fill the header fields
->put the value back
* I'm sure there are other suggestions too
http://www.BiloBeauty.com
http://www.autismspeaks.org