0

Dears, I'm using Microsoft Dynamics AX2012 R3

The Case: I want to make a custom lookup in Inventory Management ==> Journals ==> Item Transactions ==> Movement ==> Lines I want to relate the Item Id to show all lines in the SalesLines Table in order to get the ItemId and It's dimensions (Config/Size/Color/Style) and when I select it I want to move the selection to the movement line.

My Solution:

Step1: I've made a custom view (viewCustomItemId) that shows all SalesLines tables and related to InventDim to show the dimensions.

Step2: I've made a custom form (frmCustomItemId) and added the view (viewCustomItemId) as a datasource and added all fields to a grid

Step3: In the form (InventJournalMovement) I've overrided the lookup method and added below code

Args                        args = new Args();
viewCustomItemId            _viewCustomItemId;

args.name(formstr(frmCustomItemId));
args.caller(element);
newPopup = classFactory.formRunClass(args);
this.performFormLookup(newPopup);
newPopup.init();
newPopup.wait();

if (newPopup.closedOk())
    {
        _viewCustomItemId = newPopup.docCursor();

        InventJournalTrans.ItemId       = _viewCustomItemId.ItemId;
        InventDim.configId              = _viewCustomItemId.configId;
        InventDim.InventSizeId          = _viewCustomItemId.InventSizeId;
        InventDim.InventColorId         = _viewCustomItemId.InventColorId;
        InventDim.InventStyleId         = _viewCustomItemId.InventStyleId;

        InventJournalTrans_DS.research();
    }

Problem: When the lookup form is closed all fields are set to the movement line but I get warning message (Field 'Item number' must be filled in.) and the line number in the database are set to be minus for this line and also the default site and warehouse for this Item is not automatically set.

Question: Looks like I've retrieved the values but didn't pass it correctly to the lookup of the field, I don't understand what exactly I missed to make it work normally.

Thanks in advance.

  • An obvious question, but have you tried putting a breakpoint on the `InventJournalTrans.ItemId = _viewCustomItemId.ItemId;` line to see if it contains a value? – Alex Kwitny Dec 02 '20 at 22:13
  • @AlexKwitny Yes I've tried that and it has the value and the value are passed and appeared in the Movement lines form with it's dimensions once the lookup custom form is closed but still getting the same issue. – Marlis Havroc Dec 03 '20 at 07:08

1 Answers1

1

I'm surprised I missed this at first glance.

This line is your problem:

InventJournalTrans_DS.research();

You're researching before you've updated/written the data. I'm not sure why you're researching in the first place, but you have to do one or the other. Write/Update, then research or don't research. The research is where you're losing the ItemId you've input.

Alex Kwitny
  • 11,211
  • 2
  • 49
  • 71
  • Sorry for late answer, It's good point of view to not research in this part and I don't even remember why and when I've added it. Maybe during the several time of trying to figure out the problem However, Removing this line didn't fix the problem The line still doesn't feel the changes of the ItemId despite of the value appears normally. – Marlis Havroc Dec 06 '20 at 07:57