Auto fill fields on form

Prototype1
Member Posts: 37
Hi all,
I have a code field on my Contact table(Salesperson Code) I want to write to new Quotations automatically, but I can't get it to work. I have added the field to the Sales Header key and verified it before running the form.
Any suggstions?
Thanks
Tim ](*,)
I have a code field on my Contact table(Salesperson Code) I want to write to new Quotations automatically, but I can't get it to work. I have added the field to the Sales Header key and verified it before running the form.
Any suggstions?
Thanks
Tim ](*,)
0
Answers
-
-
Ok, Details.
I have the following code run "OnPush" from a "New Quote" Command button on my Sales List Form.
CASE GETFILTER("Document Type") OF
'Order' : lrecSH."Document Type" := lrecSH."Document Type"::Order;
'Quote' : lrecSH."Document Type" := lrecSH."Document Type"::Quote;
ELSE
lrecSH."Document Type" := lrecSH."Document Type"::Quote;
END;
lrecSH.INSERT(TRUE);
lrecSH.VALIDATE("Sell-to Contact No.",GETFILTER("Sell-to Contact No."));
lrecSH.MODIFY(TRUE);
CASE lrecSH."Document Type" OF
lrecSH."Document Type"::Order : FORM.RUN(FORM::"Sales Order",lrecSH);
lrecSH."Document Type"::Quote : FORM.RUN(FORM::"Sales Quote",lrecSH);
END;
where lrecSH is the Sales Header Record
This opens a new Sales Quote Form 41 with the "Sell to address" fields filled in. I want the SalesPerson Code number populated as well.
Hope this helps
Tim0 -
Assuming that the salesperson code comes from the Sell-to Customer, I would personally put that in the Sell-to Customer validation code, in the Sales Header table.0
-
Thanks for the repy. I had put the following code as you suggested, but the field doesn't populate.
Cust.CheckBlockedCustOnDocs(Cust,"Document Type",FALSE,FALSE);
Cust.TESTFIELD("Gen. Bus. Posting Group");
"Sell-to Customer Template Code" := '';
"Sell-to Customer Name" := Cust.Name;
"Sell-to Customer Name 2" := Cust."Name 2";
"Sell-to Address" := Cust.Address;
"Sell-to Address 2" := Cust."Address 2";
"Sell-to City" := Cust.City;
"Sell-to Post Code" := Cust."Post Code";
"Sell-to County" := Cust.County;
"Sell-to Country/Region Code" := Cust."Country/Region Code";
"Salesperson Code" := Cust."Salesperson Code"; ///(22.05.09 TFK) M9
IF NOT SkipSellToContact THEN
"Sell-to Contact" := Cust.Contact;
"Gen. Bus. Posting Group" := Cust."Gen. Bus. Posting Group";
"VAT Bus. Posting Group" := Cust."VAT Bus. Posting Group";
"Tax Area Code" := Cust."Tax Area Code";
"Tax Liable" := Cust."Tax Liable";
"VAT Registration No." := Cust."VAT Registration No.";
"Shipping Advice" := Cust."Shipping Advice";
"Type of Supply Code" := Cust."Type of Supply Code";
"Responsibility Center" := UserMgt.GetRespCenter(0,Cust."Responsibility Center");
VALIDATE("Location Code",UserMgt.GetLocation(0,Cust."Location Code","Responsibility Center"));
I have checked the Customer table and the "Salesperson Code" field is on the table and populated. Any further thoughts?0 -
Have you run the debugger to see if that field gets cleared some other place? Where you put that line of code is where I would start too, but sometimes stuff doesn't happen right when you try it the first time. Your code might populate that field perfectly, but there might be something else going on, which you should investigate by running the debugger. You can't just add some code, and decide that it doesn't work if the results are not what you expect.0
-
Point taken.....though debugger didn't throw up any obvious resons that it didn't work. A bit of thought and adding some more code to the "salesperson Code" OnValidate has fixed the problem.
Thanks for the help.
Tim0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions