Advanced MODIFY

oioi007
Member Posts: 41
hello
I want to make a Button that will change all <Shipping Agent Codes> by <Salesperson Code> in <Customer> Table.
On a Salespeople form I've added a TEXTBOX with "Shipping Agent Codes" SourceEXpr.
for example, When I'll change <Shipping Agent Code> (DHL) to <Salesperson Code> (AH) there will be added a Button "Change", that'll change all (AH) Salespersons with (DHL) Shipping Agent Codes in Customer Table.
I've wrote the following code on
OnPush Trigger
ShippingAgent.SETRANGE(Code);
Salesperson.SETRANGE(Code);
Customer.SETRANGE("Shipping Agent Code");
IF ShippingAgent.FINDFIRST THEN
REPEAT
Salesperson.SETRANGE(Code);
ShippingAgent.SETRANGE(Code);
IF Salesperson.FINDFIRST() THEN
REPEAT
Customer.SETFILTER(Customer."Salesperson Code", Salesperson.Code);
Customer.SETFILTER(Customer."Shipping Agent Code", ShippingAgent.Code);
IF Customer.FINDFIRST() THEN
REPEAT
Customer."Shipping Agent Code" :=ShippingAgent.Code;
Customer.MODIFY;
UNTIL Customer.NEXT = 0;
UNTIL Salesperson.NEXT= 0;
UNTIL ShippingAgent.NEXT =0;
what's wrong with this code,
please someone help me
I'll appriciate it
I want to make a Button that will change all <Shipping Agent Codes> by <Salesperson Code> in <Customer> Table.
On a Salespeople form I've added a TEXTBOX with "Shipping Agent Codes" SourceEXpr.
for example, When I'll change <Shipping Agent Code> (DHL) to <Salesperson Code> (AH) there will be added a Button "Change", that'll change all (AH) Salespersons with (DHL) Shipping Agent Codes in Customer Table.
I've wrote the following code on
OnPush Trigger
ShippingAgent.SETRANGE(Code);
Salesperson.SETRANGE(Code);
Customer.SETRANGE("Shipping Agent Code");
IF ShippingAgent.FINDFIRST THEN
REPEAT
Salesperson.SETRANGE(Code);
ShippingAgent.SETRANGE(Code);
IF Salesperson.FINDFIRST() THEN
REPEAT
Customer.SETFILTER(Customer."Salesperson Code", Salesperson.Code);
Customer.SETFILTER(Customer."Shipping Agent Code", ShippingAgent.Code);
IF Customer.FINDFIRST() THEN
REPEAT
Customer."Shipping Agent Code" :=ShippingAgent.Code;
Customer.MODIFY;
UNTIL Customer.NEXT = 0;
UNTIL Salesperson.NEXT= 0;
UNTIL ShippingAgent.NEXT =0;
what's wrong with this code,
please someone help me
I'll appriciate it

0
Answers
-
hm...
This code is changing all "Shipping Agent Code" from Customer table with
"Shipping Agent Codes" from Salespeople table. Put this code to the button's OnPush trigger.
One local variable Customer - Record Table 5200CLEAR(Customer); Customer.SETFILTER("Salesperson Code", Rec.Code); IF customer.FINDSET THEN Customer.MODIFYALL("Shipping Agent Code",Rec."Shipping Agent Codes");
I hope that this will help You...0 -
Previous code was changing "Shipping Agent Codes" for current selected SalesPeople.
This code is making it for all SalesPeople:CLEAR(salepeople); IF salepeople.FIND('-') THEN REPEAT CLEAR(customer); customer.SETFILTER("Salesperson Code", salepeople.Code); IF customer.FIND('-') THEN customer.MODIFYALL("Shipping Agent Code",salepeople."Shipping Agent Codes"); UNTIL salepeople.NEXT = 0;
0 -
krzychub83 wrote:
customer.SETFILTER("Salesperson Code", salepeople.Code); IF customer.FIND('-') THEN customer.MODIFYALL("Shipping Agent Code",salepeople."Shipping Agent Codes");
Why you are using FIND('-') if you just want to know if the table IsEmpty? ;-)0 -
hope i understand:
on salesperson you have the field "Shipping Agent Code". Now, if you change the value in this field on a Salesperson, in all customers, with the same salesperson code, should the "Shipping Agent Code" modified to the new value from sales person card. :?:
1. Your new field has a table realtion to the table "Shipping Agent"
2. now the source behind you button or behind the OnAfterValidate() Trigger of the field "Shipping Agent Code" in table sales person (13)if not confirm('Your question?',no) then exit; Customer.reset; Customer.setrange("Sales Person Code",Rec.Code); Customer.setrange("Shipping Agent Code",xRec."Shipping Agent code"); Customer.modifyall("Shipping Agent Code",Rec."Shipping Agent code");
Thats all.
RegardsDo you make it right, it works too!0 -
kine wrote:Why you are using FIND('-') if you just want to know if the table IsEmpty? ;-)
It's a very bad habit... Thx Kine0 -
Great, it works now!
Thank you very much 8)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