Problem with syntax of text string

bbrownbbrown 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.
There are no bugs - only undocumented features.

Answers

  • DaveTDaveT Member Posts: 1,039
    Hi,

    Try,

    message( '%1.SETFILTER("Entry No.", ''>%2'', FilterStart);', 'SalesHeader', '%1' );
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • DaveTDaveT Member Posts: 1,039
    Note : the '' beside the >%2 is two single quotes and not a double quote as it reads the the human eye
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • bbrownbbrown Member Posts: 3,268
    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.
  • DaveTDaveT Member Posts: 1,039
    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.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • bbrownbbrown Member Posts: 3,268
    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.
  • DaveTDaveT Member Posts: 1,039
    Glad to Help :mrgreen:

    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.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.