Question Status

Verified
dwcwork asked a question on 5 Nov 2013 10:37 AM

I wrote the following job - to learn more about how AX and X++ work, but it is driving me crazy. 

It is having problems with this line below: qbr2 = qbds1.addRange(fieldNum(dimensionAttributeValueSetItem,DisplayValue));

When I run it, it gives a critical stop and says:  Invalid range.    It is a valid field in DimensionAttributeValueSetItem, but for some reason it doesn't think so. 

I have been over my program multiple times and cannot find any error - what would make it give an error like that?  What am I missing?

 

 

static void DantestInventTable(Args _args)

//Define Query

{

Query             query;

QueryRun        queryRun;

QueryBuildDataSource     qbds1;

QueryBuildDataSource     qbds2;

QueryBuildRange        qbr1;

QueryBuildRange        qbr2;

InventTable     inventTable;

DimensionAttributeValueSetItem dimensionAttributeValueSetItem;

Struct structOutput;

   structOutput = new struct

   ("str ItemTableID;"

   + "str DisplayValue;"

   );

//the Build

query = new Query();

qbds1 = query.addDataSource(TableNum(InventTable));

  qbds1.addSortField(fieldNum(InventTable,ItemId));

   qbr1 = qbds1.addRange(fieldNum(inventTable,SemRevenueType));

   qbr1.value("Essential 08-01");

   qbr2 = qbds1.addRange(fieldNum(dimensionAttributeValueSetItem,DisplayValue));

   qbr2.value("P25");

qbds2 = qbds1.addDataSource(TableNum(DimensionAttributeValueSetItem));

qbds2.relations(false);

qbds2.joinMode(joinmode::ExistsJoin);

qbds2.addLink(fieldnum(InventTable,DefaultDimension),fieldnum(DimensionAttributeValueSetItem,DimensionAttributeValueSet));

//the Instantiation

queryRun = new queryRun(query);

//the Action

// the If condition checks to see that the query is running.  If not, it will not execute.

if (queryRun.prompt())

{

//the while loops over the InventTable in search of the information needed.

   while (queryRun.next())

   {

       inventTable = queryRun.get(tableNum(InventTable));

       dimensionAttributeValueSetItem = queryRun.get(tableNum(DimensionAttributeValueSetItem));

       structOutput.value("ItemTableID",inventTable.ItemId);

       structOutput.value("DisplayValue",dimensionAttributeValueSetItem.DisplayValue);

       info(structOutput.toString());

   }

}

Reply
Verified Answer
tturney responded on 5 Nov 2013 11:32 AM

DWCWORK,

 It looks like you have set the range with a field in the dimensionAttributeValueSetItem table, but the QueryBuildDataSource (qbds1) is the inventtable.

Tom T.

Reply
dwcwork responded on 5 Nov 2013 11:38 AM

As you can tell, I am new at this.  How do I add the range for the dimensionAttributeValueSetItem as well at the inventTable?  I have been looking all over the web, and can't find anything that explains this very well.

Reply
dwcwork responded on 5 Nov 2013 2:18 PM

figured that part out - played with it some more!

Reply
tturney responded on 6 Nov 2013 11:52 AM

Thats great.  Sometimes it just takes experimentation, and alot of Bing/Google.

Reply
dwcwork responded on 7 Nov 2013 12:54 PM

I just wish there was more about some of these topics in Bing/Google.  Have to do a ton of searching for the little gems that are hidden out there - and with many blogs reposting the same post - can get very frustrating.  I do the Web searches first and when I can't find what I need I then post here asking for help.  So far this Forum has helped me with the three major problems I couldn't solve any other way.  You all are a great help!

Reply
Irum Faisal responded on 10 Mar 2015 4:19 AM

Hi all,

We are using AX2012 R2 CU7. AX is throwing "Invalid Range" error (as shown in snapshot below) whenever we try to access "Product Dimension Group" function from modules "Product Information Management-->Release products" or "Retail-->Products-->Released Products by Category" forms.

Any Idea, why this error happens and how to resolve it. Your help/guidance will be highly appreciated. 

Reply
Suggested Answer
Umer Ejaz responded on 10 Sep 2015 4:07 AM

I ran into this same problem today. i started getting invalid range on a customized field ProjInvoiceJour.Settlement. In another task i was working on i had to delete and reimport this field into the enviroment after that our customer started getting invalid range on higlighted line show under.

    QueryBuildDataSource    queryData;
    ;
   

    query = new Query();

    query.addDataSource(tablenum(ProjInvoiceJour));
    queryData = query.dataSourceTable(tablenum(ProjInvoiceJour));

    queryData.addRange(fieldnum(ProjInvoiceJour, SettlementNumber)).value('""');
    queryData.rangeField(fieldnum(ProjInvoiceJour, SettlementNumber)).status(RangeStatus::LOCKED);
    queryData.addRange(fieldnum(ProjInvoiceJour, ProjInvoiceId));
    queryData.addRange(fieldnum(ProjInvoiceJour, InvoiceDate));
    queryData.addRange(fieldnum(ProjInvoiceJour, ProjInvoiceProjId));

Solution:

Simply make any change to the line, for example, remove a comma and put it back and compile the thing again. after that you should not get Invalid range on this line. You probably needs to do the same all of the places where affected field is just in the same manner.

Reply
Verified Answer
tturney responded on 5 Nov 2013 11:32 AM

DWCWORK,

 It looks like you have set the range with a field in the dimensionAttributeValueSetItem table, but the QueryBuildDataSource (qbds1) is the inventtable.

Tom T.

Reply
Suggested Answer
Umer Ejaz responded on 10 Sep 2015 4:07 AM

I ran into this same problem today. i started getting invalid range on a customized field ProjInvoiceJour.Settlement. In another task i was working on i had to delete and reimport this field into the enviroment after that our customer started getting invalid range on higlighted line show under.

    QueryBuildDataSource    queryData;
    ;
   

    query = new Query();

    query.addDataSource(tablenum(ProjInvoiceJour));
    queryData = query.dataSourceTable(tablenum(ProjInvoiceJour));

    queryData.addRange(fieldnum(ProjInvoiceJour, SettlementNumber)).value('""');
    queryData.rangeField(fieldnum(ProjInvoiceJour, SettlementNumber)).status(RangeStatus::LOCKED);
    queryData.addRange(fieldnum(ProjInvoiceJour, ProjInvoiceId));
    queryData.addRange(fieldnum(ProjInvoiceJour, InvoiceDate));
    queryData.addRange(fieldnum(ProjInvoiceJour, ProjInvoiceProjId));

Solution:

Simply make any change to the line, for example, remove a comma and put it back and compile the thing again. after that you should not get Invalid range on this line. You probably needs to do the same all of the places where affected field is just in the same manner.

Reply