How to avoid duplication when importing invoices?

Vesna
Member Posts: 24
Hey everyone,
I need to create a code that prevent the customer from duplication importing the same 1000 invoices.
Right now, I created the following code:
IF ("Document No.") EXIST
Then Begin
CurrDataport. SKIP;
END;
But system gives me an error.
Any suggestions please.
[-o<
I need to create a code that prevent the customer from duplication importing the same 1000 invoices.
Right now, I created the following code:
IF ("Document No.") EXIST
Then Begin
CurrDataport. SKIP;
END;
But system gives me an error.
Any suggestions please.
[-o<
0
Comments
-
Have you thought about changing the property on the Sales header dataitem
AutoUpdate=NO
AutoReplace=NO0 -
Vesna wrote:IF ("Document No.") EXIST
Then Begin
CurrDataport. SKIP;
END;0 -
to Savatage,
I created dataport in Purchase Line so when I do
AutoUpdate=NO
AutoReplace=NO
I can not import anything. Our client is going to use this dataport from time to time to import its invocies so customers' No and Names can repeat.
I need system to identify by invoice No. that this invoice has been already imported. Because if client imports 1000 invoices and then found out that these invocies have been already imported and posted recently, of course it is not fun for him to delete them one by one.
To DenSter,
It does not. I thought I saw this somewhere on the forum.0 -
Where are you importing your data? To the Sales Header table or the Gen. Journal Line table?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
I am importing Purchase invoices through dataport created in Purchase Line0
-
can we assume you're creating the purchase header using your dataport?
Hmm - Autoreplace = No always prevents overwriting for me :-k0 -
Savatage,
"Hmm - Autoreplace = No always prevents overwriting for me"
Yes, that is right, but only when invoices not posted yet.
As soon as I post invoices N.1, N.2, N.3 they disapper.
When I (let's say mistakenly) import them again. System allows me to do this but when I am trying to post them it tells me that invoices with this Vendor Inovice No. already exist.
In this case I have to delete all imported invoices (what a huge work if I imported 1000)
So I want the system to identify by Invoice No. that this invoices have been already imported and posted.
Thank you0 -
Ahh that's very different - so you are automatically filling in the Posting No. then instead of letting Nav assign the next available one.
Your Not using the posted Purchase Invoice No Series.
So you want to take the Puchase Line Doc No & Search the Purch. Inv Header first to see if it exists first.0 -
Thank you for the reply Savatage,
But honestly it is not very clear to me.
Can you give me a hint of C/AL code for it.
Highly appreciate
Vesna0 -
Are you using variables to load your data?
How About
OnAfterImportRecord()IF "Purch. Inv. Header".GET("Purchase Line".Document No.") THEN CurrDataport.SKIP ELSE BEGIN .. All the rest END;
0 -
Thank you Savatage,
Yes, I am using variables to import my data.
Now, I realise that it better if I will use Vendor Invoice No. as identified point, because this number remained the same when invoice is posted, while Document No can be changed by the system according to N. Serial for Posted Purchase Invoices.
So on the basis of your code I tryed different combination but it doesn't work for me.](*,)
The dataport accept the following code:
PurchaseHeaderRec.RESET;
If PurchaseHeaderRec. GET(VIN)
Then begin
CurrDataport.SKIP;
END;
where VIN is my variable for Vendor Invoice No.
But when I am trying to import file I see the message "The expression Text cannot be type-converted to a Option value"
If there are any ideas I appreciate greatly because I already have doubts that there is a solution for this.
:roll:0 -
The expression Text cannot be type-converted to a Option value"
There must be more code than you're showing us.
What is VIN again? the Posted Purch Inv No? or some Order No? or something?
is VIN a key?If PurchaseHeaderRec.GET(VIN) Then begin CurrDataport.SKIP End Else Begin .. <Mapping of variables happening here> .. END;
Is PurchaseHeaderRec a Variable for The Purchase Header or Purchase Inv Header?0 -
we import Orders and on import of the The Order# I also added
SalesHeader."Posting No" := varOrderNo;
SalesHeader."Shipping No" :=varOrderNo;
This way on posting all the Numbers match all the way thru from order to invoice.
This code works for us to prevent the duplication of imported orders.IF SalesInvHeader.GET(varOrderNo) THEN CurrDataport.SKIP ELSE BEGIN .. All the rest END;
If your not going to use the key - then I think a FIND function is needed0 -
keep numberin'....
good luckMCSD
Attain Navision0
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