Options

SETGANGE doesn't allow more than 3 characters

knaabisknaabis Member Posts: 37
I need to get in my report from CrossReference Table some info with SETRANGE like this:

CLEAR(CrossRef1);
CrossRef1.SETRANGE("Description",CrossRef1."Description"::Box1);
CrossRef1.SETRANGE("Item No.","Item"."No.");
IF CrossRef1.FIND('-') THEN;

I get error message "The text 'BOX1' is too long. Text can have maximum lenght 3 characters."

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    What is the Data Type of field CrossRef1.Description? If it is Text, you have to use something like:

    CrossRef1.SETRANGE(Description,'Box1');
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    knaabisknaabis Member Posts: 37
    If you mean like this, then also doesn't work...

    CLEAR(CrossRef1);
    CrossRef1.SETRANGE(Description,'Box1');
    CrossRef1.SETRANGE("Item No.","Item"."No.");
    IF CrossRef1.FIND('-') THEN;
  • Options
    ChinmoyChinmoy Member Posts: 359
    Did you change any field ids in the table? It looks like that the field in the SetRange should not be description, because description is a text field, why would you setrange on it with an option. Probably what has happened is there was a field with type Option which has got changed and the description field has somehow got the id of the option field.

    Chn
  • Options
    dansdans Member Posts: 148
    what is the data type and length of the Description field ?
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • Options
    knaabisknaabis Member Posts: 37
    edited 2012-06-07
    i think this is text field, but I'm not sure, because i haven't access in Table design...
    This is Item Cross Reference Table - 5717
  • Options
    ChinmoyChinmoy Member Posts: 359
    Is it possible for you to detect whether there was a change in the Field Ids in this table?

    Chn
  • Options
    ufukufuk Member Posts: 514
    knaabis wrote:
    I get error message "The text 'BOX1' is too long. Text can have maximum lenght 3 characters."

    The message says CrossRef1.Description is a text field and length is 3 character. But when I read your code description appears as a option field. There is an inconsistency between the error message and the code. Have you been able to compile this object and receive this message after that?
    Ufuk Asci
    Pargesoft
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    knaabis wrote:
    If you mean like this, then also doesn't work...

    CLEAR(CrossRef1);
    CrossRef1.SETRANGE(Description,'Box1');
    CrossRef1.SETRANGE("Item No.","Item"."No.");
    IF CrossRef1.FIND('-') THEN;
    Please clarify "doesn't work": can the code be compiled or is the result not what you expected?
    Maybe "Box1" is written differently in the CrossRef table.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    knaabisknaabis Member Posts: 37
    knaabis wrote:
    If you mean like this, then also doesn't work...

    CLEAR(CrossRef1);
    CrossRef1.SETRANGE(Description,'Box1');
    CrossRef1.SETRANGE("Item No.","Item"."No.");
    IF CrossRef1.FIND('-') THEN;
    Please clarify "doesn't work": can the code be compiled or is the result not what you expected?
    Maybe "Box1" is written differently in the CrossRef table.
    Yes...
    Box1 and BOX1

    Thanks for help!
  • Options
    dansdans Member Posts: 148
    did the error happen when you run it or when you save it ?
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    knaabis wrote:
    Box1 and BOX1
    CrossRef1.SETFILTER(Description, '%1', '@box1');
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
Sign In or Register to comment.