Options

How to include the DateFilter in the function???

poppinspoppins Member Posts: 647
edited 2012-07-09 in NAV Three Tier
Hi everyone,

I have to use the following function:
GenerateMatrixData(SetWanted,MaximumSetLength,UseNameForCaption,PeriodType,DateFilter,PKFirstRedInCurrSet,CaptionSet,CaptionRange,CurrSetLength,PeriodRecords)

The DateFilter parameter's type is Text and its max length is 30.

Now, the filter I have to use is the following:
SETFILTER("Period Start",'>=%1',DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1)));

How should I pass that to the function????
I am really new to C/AL code and I didn't do a lot of practice so I usually get confused when it's about writing code :oops: :oops:
Any help would be most welcome...

Answers

  • Options
    poppinspoppins Member Posts: 647
    Infact, the function automatically assigns the value of the parameter DateFilter to Period Start so I don't really need to specify that the filter is on Period Start...

    I tried to introduce the DateFilter parameter this way:
    GenerateMatrixData(SetWanted,MaximumSetLength,UseNameForCaption,PeriodType,'>=DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1))',PKFirstRedInCurrSet,CaptionSet,CaptionRange,CurrSetLength,PeriodRecords)
    

    but I got the following error message:
    Overflow under type conversion of text to text
    Value: DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1))
    

    What should I do???
  • Options
    ChinmoyChinmoy Member Posts: 359
    Put the value in a date variable

    TempDate := DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1));

    then pass

    '>=FORMAT(TempDate)'

    This shud work.. :)

    Chn
  • Options
    poppinspoppins Member Posts: 647
    Chinmoy wrote:
    Put the value in a date variable

    TempDate := DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1));

    then pass

    '>=FORMAT(TempDate)'

    This shud work.. :)

    Chn

    Actually, it didn't work :(

    I even tried :
    TextDate := '>=FORMAT(TempDate)';
    
    where TextDate is a variable of type Text and then passed it to the function....

    The result is the following error:
    '>=FORMAT(TempDate)' is not a valid date...
    

    What can I do???
  • Options
    poppinspoppins Member Posts: 647
    I finally did it....That's how I proceeded:
    TempDate := DMY2DATE(1,1,(DATE2DWY(TODAY,3)-1));
    TextDate := FORMAT(TempDate);
    
    DateFilter := '>= '+TextDate;
    

    And I passed DateFilter to the function....It works :D

    Thank you Chinmoy, you've been of a great help :D
  • Options
    ChinmoyChinmoy Member Posts: 359
    You are welcome... :)

    please mark the post as solved.

    Chn
Sign In or Register to comment.