COPYFILTER between 2 similar but different record

andy76
Member Posts: 616
Hello,
I need to copy all filters between 2 similar but different record (from "Sales Header" to "Sales Header Archive").
COPYFILTERS wants same record...
Is that possible? With some automatic cycle? How?
Thank you
I need to copy all filters between 2 similar but different record (from "Sales Header" to "Sales Header Archive").
COPYFILTERS wants same record...
Is that possible? With some automatic cycle? How?
Thank you
0
Comments
-
-
Hi,
You could also use GETVIEW and SETVIEW
Albert0 -
I.e. like this:
OBJECT Codeunit 50000 Transfer Filters { OBJECT-PROPERTIES { Date=24-09-08; Time=23:14:38; Modified=Yes; Version List=; } PROPERTIES { OnRun=VAR l_SalesHeader@1000000000 : Record 36; l_SalesHeaderArchive@1000000001 : Record 5107; l_FromRecRef@1000000002 : RecordRef; l_ToRecRef@1000000003 : RecordRef; BEGIN l_SalesHeader.SETRANGE("Document Type",l_SalesHeader."Document Type"::Order); l_SalesHeader.SETRANGE("Your Reference",'X'); l_SalesHeader.SETRANGE("No. Printed",0); // Will cause error because the field doesn't exist in the archive //l_SalesHeader.SETRANGE("Send IC Document",TRUE); // Will cause error because of different field type //l_SalesHeader.SETRANGE("No. of Archived Versions",1); l_FromRecRef.GETTABLE(l_SalesHeader); l_ToRecRef.OPEN(DATABASE::"Sales Header Archive"); TransferFilters(l_FromRecRef,l_ToRecRef,FALSE); l_SalesHeaderArchive.SETVIEW(l_ToRecRef.GETVIEW(FALSE)); MESSAGE(l_SalesHeaderArchive.GETFILTERS); END; } CODE { PROCEDURE TransferFilters@1000000001(VAR p_FromRecRef@1000000000 : RecordRef;VAR p_ToRecRef@1000000001 : RecordRef;p_IgnoreIncompatibleFilters@1000000002 : Boolean); VAR l_Field@1000000006 : Record 2000000041; l_FromFldRef@1000000003 : FieldRef; l_ToFldRef@1000000004 : FieldRef; l_FldNo@1000000005 : Integer; BEGIN // Known errors and limitations: // * Filtergroups are ignored // * High number of complex filters can result in overflow in the SETVIEW/GETVIEW line FOR l_FldNo := 1 TO p_FromRecRef.FIELDCOUNT DO BEGIN l_FromFldRef := p_FromRecRef.FIELDINDEX(l_FldNo); IF l_FromFldRef.GETFILTER <> '' THEN BEGIN IF l_Field.GET(p_ToRecRef.NUMBER,l_FromFldRef.NUMBER) THEN BEGIN l_ToFldRef := p_ToRecRef.FIELD(l_FromFldRef.NUMBER); IF l_FromFldRef.TYPE = l_ToFldRef.TYPE THEN l_ToFldRef.SETFILTER(l_FromFldRef.GETFILTER) ELSE IF NOT p_IgnoreIncompatibleFilters THEN ERROR( 'Filter on the "%1" field cannot be copied from the %2 table to\' + 'the "%3" field in the %4 table due to different field types. (%5 vs. %6)\\' + 'Please remove this field filter and try again.', l_FromFldRef.CAPTION,p_FromRecRef.CAPTION, l_ToFldRef.CAPTION,p_ToRecRef.CAPTION, l_FromFldRef.TYPE,l_ToFldRef.TYPE); END ELSE IF NOT p_IgnoreIncompatibleFilters THEN ERROR( 'Filter on the "%1" cannot be copied from the %2 table\' + 'since field number %3 does not exist in the %4 table.\\' + 'Please remove this field filter and try again.', l_FromFldRef.CAPTION,p_FromRecRef.CAPTION, l_FromFldRef.NUMBER,p_ToRecRef.CAPTION); END; END; END; BEGIN { Code by Peter D. Jorgensen - 2008 } END. } }
Regards
Peter0
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