Problem with syntax of text string
bbrown
Member Posts: 3,268
I am using a text string with replacement parameters but also need to include the parameter %1 as a literal part of the string. The first string I tried was:
'%1.SETFILTER("Entry No.", '>%1', FilterStart);'
The first %1 is a replacement parameter that should be replaced by a record variable name. The second %1 is a constant. Let's say my record variable is SalesHeader. This string resulted in:
SalesHeader.SETFILTER("Entry No.", '>SalesHeader', FilterStart);
I then tried:
'%1.SETFILTER("Entry No.", '>%%1', FilterStart);'
This resulted in:
SalesHeader.SETFILTER("Entry No.", '>%SalesHeader', FilterStart);
What I want for a result is:
SalesHeader.SETFILTER("Entry No.", '>%1', FilterStart);
Any thoughts?
Thanks.
'%1.SETFILTER("Entry No.", '>%1', FilterStart);'
The first %1 is a replacement parameter that should be replaced by a record variable name. The second %1 is a constant. Let's say my record variable is SalesHeader. This string resulted in:
SalesHeader.SETFILTER("Entry No.", '>SalesHeader', FilterStart);
I then tried:
'%1.SETFILTER("Entry No.", '>%%1', FilterStart);'
This resulted in:
SalesHeader.SETFILTER("Entry No.", '>%SalesHeader', FilterStart);
What I want for a result is:
SalesHeader.SETFILTER("Entry No.", '>%1', FilterStart);
Any thoughts?
Thanks.
There are no bugs - only undocumented features.
0
Answers
-
Hi,
Try,
message( '%1.SETFILTER("Entry No.", ''>%2'', FilterStart);', 'SalesHeader', '%1' );0 -
Note : the '' beside the >%2 is two single quotes and not a double quote as it reads the the human eye0
-
Thanks for the reply.
I'm not sure this i smy solution but it does help point me in a direction. I cannnot hardcode 'Salesheader'. That was just an example. This code is contained in a loop and is being passed several record variable names which in turn are populated by their own replacement parameters. What I am working with is the "Create Field Checking Code" from the SQL Migrate toolkit.There are no bugs - only undocumented features.0 -
Hi,
The hardcoding was just a test - I think the concept of using the %2 to substitue in the %1 is what you need. Also I have found that using text constants are helpful getting around coding issue like these.0 -
Issue solved. Thanks for the idea.
What I had to do was modify the PrintLine function to pass a 7th parameter with a constant value of '%1'. Same as your example, just %2 was already being used. My final text constant looks like this:
'%1.SETFILTER("Entry No.", '>%7', FilterStart);'
I then pass it to the PrintLine function which as been changed like this:
TextFile.WRITE(
STRSUBSTNO(
PADSTR('',Indentation) + NewLine,
TableVarName(1),'"' + Field.FieldName + '"',Object.ID,TableVarName(2),VariableID,ProcedureID,'%1'));
The end result is this:
A17.SETFILTER("Entry No.", '>%1', FilterStart);
A little back ground:
What I am doing is modifying the SQL Migrate process so it can restart processing some table where it left off. While this approach won't work with all tables, I'm only doing it with tables that use increasing integers as primary key, it will allow the migrate process to be conducted of several runs.There are no bugs - only undocumented features.0 -
Glad to Help

It's issues like this that drive me crazy when you want to get on and solve the main problem.
Sounds like a interesting project.0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 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