Why cannot modify record in Dataport?
bluerock
Member Posts: 32
I create a dataport for importing data, and re-calculate the amount. But it won't update the amount, any mistake in my coding? thank you.
OBJECT Dataport 90002 Item2007Opening ImpUpdate
{
OBJECT-PROPERTIES
{
Date=24/07/09;
Time=[ 4:49:55 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
FileFormat=Variable;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table90021;
AutoSave=Yes;
AutoUpdate=Yes;
AutoReplace=Yes;
DataItemTableView=SORTING(Item No.);
OnAfterImportRecord=BEGIN
g_recItem2007Opening.SETFILTER("Item No.","Item 2007 Opening"."Item No.");;
IF g_recItem2007Opening.FIND('-') THEN
BEGIN
g_recItem2007Opening.GET("Item 2007 Opening"."Item No.");
intAmount := g_recItem2007Opening."Unit Cost" * g_recItem2007Opening.Quantity;
g_recItem2007Opening.Amount := intAmount;
//g_recItem2007Opening.VALIDATE(Amount, intAmount);
g_recItem2007Opening.MODIFY;
END;
END;
}
FIELDS
{
{ ; ;"Item No." }
{ ; ;Quantity }
{ ; ;"Unit Cost" }
{ ; ;Amount }
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
g_recItem2007Opening@1000000000 : Record 90021;
intAmount@1000000001 : Integer;
BEGIN
{
/* This is used to import the "Unit Cost" into the table 'Item 2007 Opening'
/* And then re-calculatte the amount ["Unit Cost" * Quantity] in the table 'Item 2007 Opening'
/* The .csv file just contains two columns: 1) Item No. 2) Unit Cost
}
END.
}
}
OBJECT Dataport 90002 Item2007Opening ImpUpdate
{
OBJECT-PROPERTIES
{
Date=24/07/09;
Time=[ 4:49:55 PM];
Modified=Yes;
Version List=;
}
PROPERTIES
{
FileFormat=Variable;
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table90021;
AutoSave=Yes;
AutoUpdate=Yes;
AutoReplace=Yes;
DataItemTableView=SORTING(Item No.);
OnAfterImportRecord=BEGIN
g_recItem2007Opening.SETFILTER("Item No.","Item 2007 Opening"."Item No.");;
IF g_recItem2007Opening.FIND('-') THEN
BEGIN
g_recItem2007Opening.GET("Item 2007 Opening"."Item No.");
intAmount := g_recItem2007Opening."Unit Cost" * g_recItem2007Opening.Quantity;
g_recItem2007Opening.Amount := intAmount;
//g_recItem2007Opening.VALIDATE(Amount, intAmount);
g_recItem2007Opening.MODIFY;
END;
END;
}
FIELDS
{
{ ; ;"Item No." }
{ ; ;Quantity }
{ ; ;"Unit Cost" }
{ ; ;Amount }
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=9020;
Height=3410;
}
CONTROLS
{
}
}
CODE
{
VAR
g_recItem2007Opening@1000000000 : Record 90021;
intAmount@1000000001 : Integer;
BEGIN
{
/* This is used to import the "Unit Cost" into the table 'Item 2007 Opening'
/* And then re-calculatte the amount ["Unit Cost" * Quantity] in the table 'Item 2007 Opening'
/* The .csv file just contains two columns: 1) Item No. 2) Unit Cost
}
END.
}
}
0
Comments
-
Try adding a MESSAGE just after the line g_recItem2007Opening.MODIFY; to see if this line is being executed or not.
And why you first do a g_recItem2007Opening.GET after you did a IF g_recItem2007Opening.FIND('-') THEN is mystery to me.No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
BTW : if you run the dataport directly in design-mode, it will NOT do a implicit COMMIT at the end. For this you need to run the dataport from the object designer or from the menu or from another object.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
