Options

Nav 5.1 Setrange Error

MorilenMorilen Member Posts: 30
I am attempting to add another SETRANGE parameter when data is pulled from the Customer Equipment (custom) table.
CustEquip is set as a record under Global Variables for that table. 'New' is one of the options you can choose when entering data into the "Asset Status" field. I have several records that already exist with this value and simply want it to only take values of 'New' and ignore values of 'Deactivated'. The rest of the code works perfectly and I only get the error below when I add in the Bold line.

Any help would be greatly appreciated.
:)

MajortotalQty := 0;
MinorQty := 0;
CustEquip.RESET;
CustEquip.SETRANGE("Customer No.","Sales Header"."Sell-to Customer No.");
CustEquip.SETRANGE(Type,1);
CustEquip.SETRANGE("Item No.",'Q1002');
//custequip.setrange(Quantity,0);
IF CustEquip.FIND('-') THEN
MinorQty := CustEquip.COUNT;

CustEquip.RESET;
CustEquip.SETRANGE("Customer No.","Sales Header"."Sell-to Customer No.");
CustEquip.SETRANGE(Type,0);
CustEquip.SETRANGE("Item No.",'Q1002');
CustEquip.SETRANGE("Asset Status", 'New');
IF CustEquip.FIND('-') THEN
REPEAT
CustEquip.CALCFIELDS(Quantity);
MajortotalQty := MajortotalQty + CustEquip.Quantity;
UNTIL CustEquip.NEXT = 0;






Error


Type conversion is not possible because 1 of the operators contains an invalid type.

Option := Text

Comments

  • DenSterDenSter Member Posts: 8,307
    CustEquip.SETRANGE("Asset Status",CustEquip."Asset Status"::New);
    
    Internally, option type fields are stored as an integer. In C/AL code, Option type fields are enumerated by ::
  • MorilenMorilen Member Posts: 30
    DenSter wrote:
    CustEquip.SETRANGE("Asset Status",CustEquip."Asset Status"::New);
    
    Internally, option type fields are stored as an integer. In C/AL code, Option type fields are enumerated by ::


    That worked perfectly.

    Thank you.

    :D
  • DenSterDenSter Member Posts: 8,307
Sign In or Register to comment.