Copy a field to the same field on another table

DarkHorse
Member Posts: 389
Hello, I've the field "Credit Limit (LCY)" -decimal type-on Customer and Contact table. On Contact table, on Credit Limit onValidate trigger, I've the code:
recContBusinRel is Contact Bussiness Relation table
Cust is Customer table
The code copy the Credit limit field from contact table to credit limit field customer table when you go from contact tab to customer tab.
But it doesn't work on reserve, i mean, I modify the credit limit field on customer tab but it doesn't copy to credit limit contact table field. I've put the same code (changing tables obviosly) on onvalidate trigger from credit limit field on customer table, but it doesn't work. Does anybody knows what can be the problem?.
Thanks in advance.
recContBusinRel.RESET ; recContBusinRel.SETRANGE("Contact No.", "No.") ; recContBusinRel.SETRANGE("Link to Table", recContBusinRel."Link to Table"::Customer) ; IF recContBusinRel.FIND('-') THEN BEGIN Cust.RESET ; IF Cust.GET(recContBusinRel."No.") THEN BEGIN Cust."Credit Limit (LCY)" := "Credit Limit (LCY)" ; Cust.MODIFY ; END ; END ;
recContBusinRel is Contact Bussiness Relation table
Cust is Customer table
The code copy the Credit limit field from contact table to credit limit field customer table when you go from contact tab to customer tab.
But it doesn't work on reserve, i mean, I modify the credit limit field on customer tab but it doesn't copy to credit limit contact table field. I've put the same code (changing tables obviosly) on onvalidate trigger from credit limit field on customer table, but it doesn't work. Does anybody knows what can be the problem?.
Thanks in advance.
0
Comments
-
From Contact -> Customer:
Credit Limit (LCY) - OnValidate() //A Creditlimit is only possible if it is the Company and not a person ContBusRel.RESET; ContBusRel.SETRANGE("Contact No.","Company No."); ContBusRel.SETFILTER("No.",'<>'''''); ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer); IF ContBusRel.FINDFIRST THEN BEGIN Cust.GET(ContBusRel."No."); Cust."Credit Limit (LCY)" := "Credit Limit (LCY)"; Cust.MODIFY; END;
From Customer -> Contact:ContBusRel.SETCURRENTKEY("Link to Table","No."); ContBusRel.SETRANGE("Link to Table",ContBusRel."Link to Table"::Customer); ContBusRel.SETRANGE("No.","No."); if ContBusRel.findfirst then begin Contact.get(ContBusRel."Contact No."); Contact."Credit Limit (LCY)" := "Credit Limit (LCY)"; Contact.MODIFY; end;
BUT better is, if you take a look into the Codeunit "CustCont-Update" fromCustomer - OnModify Trigger UpdateContFromCust.OnModify(Rec)
and into the Codeunit "CustVendBank-Update" fromContact - OnModify(xRec : Record Contact) FUNCTION
The codesnippes above from me was only an example (but it work, better use the 2 codeunits that i post).
RegardsDo you make it right, it works too!0 -
Hi,
Can you post the reverse code - there may be a confusion with "No." vs "Contact No."0 -
Hi Garak,
No - I must be a slow typer as you posted all the code in the time it took me to post a single line of text
Must get out of the habit of leaving multiple tabs open :oops:0 -
Like my teacher used to say "must try harder"
0 -
Thanks both for help; it works perfectly!!!.
Thanks again.0
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