This is My code ,hehe It is too long
Code: "GRED_Sales Price".SETRANGE("Starting Date",080601D);
IF "GRED_Sales Price".FIND('-') THEN
REPEAT
IF "GRED_Sales Price".GET("GRED_Sales Price"."Item No.","GRED_Sales Price"."Sales Type","GRED_Sales Price"."Sales Code"
,"GRED_Sales Price"."Starting Date","GRED_Sales Price"."Currency Code","GRED_Sales Price"."Variant Code",
"GRED_Sales Price"."Unit of Measure Code","GRED_Sales Price"."Minimum Quantity") THEN
"GRED_Sales Price".RENAME("GRED_Sales Price"."Item No.",2,"GRED_Sales Price"."Sales Code",
"GRED_Sales Price"."Starting Date",'',"GRED_Sales Price"."Variant Code",'pc',"GRED_Sales Price"."Minimum Quantity");
Two observations of your code
1. why the get your already have the record with the find
2. You are using the same record variable in the rename which will reposition the record for the next.
The get should be to see if the new key exists i.e. UOM 'pc' and rename if not found.
Also use two new record variables to avoid repositioning
Two observations of your code
1. why the get your already have the record with the find
2. You are using the same record variable in the rename which will reposition the record for the next.
The get should be to see if the new key exists i.e. UOM 'pc' and rename if not found.
Also use two new record variables to avoid repositioning
Thank you DaveT!! I found my code where is bug,you are very good!!
Comments
object designer (sift +f12). open your table in table designer by clicking design button then go to view menu -> keys.
you will have list of keys. first row is a primary key of that table. other are secondary keys.
regards,
Rajesh Patel
On the other hand if you are asking how to change the data record of a primary key then use the rename function
e.g.
Note the rename function changes the position in the file and you must send all the parts of the primary key.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
"IF Customer.GET( '10000' ) THEN
BEGIN
Customer.RENAME( 'new10000' );"
Right option .
If u want to change field (which is primary key of the table ) then think the side effects .
Code:
"GRED_Sales Price".SETRANGE("Starting Date",080601D);
IF "GRED_Sales Price".FIND('-') THEN
REPEAT
IF "GRED_Sales Price".GET("GRED_Sales Price"."Item No.","GRED_Sales Price"."Sales Type","GRED_Sales Price"."Sales Code"
,"GRED_Sales Price"."Starting Date","GRED_Sales Price"."Currency Code","GRED_Sales Price"."Variant Code",
"GRED_Sales Price"."Unit of Measure Code","GRED_Sales Price"."Minimum Quantity") THEN
"GRED_Sales Price".RENAME("GRED_Sales Price"."Item No.",2,"GRED_Sales Price"."Sales Code",
"GRED_Sales Price"."Starting Date",'',"GRED_Sales Price"."Variant Code",'pc',"GRED_Sales Price"."Minimum Quantity");
UNTIL "GRED_Sales Price".NEXT=0;
Code
Two observations of your code
1. why the get your already have the record with the find
2. You are using the same record variable in the rename which will reposition the record for the next.
The get should be to see if the new key exists i.e. UOM 'pc' and rename if not found.
Also use two new record variables to avoid repositioning
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thank you DaveT!! I found my code where is bug,you are very good!!
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html