Hello! We've put a button on the Sales Invoice form (43) which when clicked adds a specific item to the subform (47). This seems to work correctly but I can't figure out how to make the new line the selected line after it's created. Specifically I want to call the InsertExtendedText function on the form right after creating the new record but in code after I do the INSERT, Rec doesn't have any values (xRec has what I want), so InsertExtendedText doesn't do anything. What I've got is a new menu button which when clicked calls a routine we've created. Within that routine is this code:
SalesLine.INIT;
SalesLine."Document Type" := SalesHeader."Document Type";
SalesLine."Document No." := SalesHeader."No.";
SalesLine."Line No." := LineNo;
SalesLine.VALIDATE("Sell-to Customer No.", SalesHeader."Sell-to Customer No.");
SalesLine.VALIDATE(Type, SalesLine.Type::Item);
SalesLine.VALIDATE("No.", 'E87360001');
SalesLine.VALIDATE(Quantity, 1);
SalesLine.INSERT;
currform.update;
message("No."); //
returns nothing
as a side request, if anybody knows how to set the top row (scroll a list to make a certain line the first visible line in the window) that would be appreciated too!
Thanks!
0
Comments
http://www.BiloBeauty.com
http://www.autismspeaks.org
So you want the cursor on the top line...When? when to form opens?
Change the SourceTablePlacement = First
Also many people made custom changes to the InsertExtText - So I assumed you didn't.
Also you can set that Item Number as a variable in a setup form like the Inventory Setup.
That way it can be changed easily at some pint if needed.
Ex/ Add A field to the Invtory Setup - "MY Default No." or whatever.
Then the code would look like...
http://www.BiloBeauty.com
http://www.autismspeaks.org
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
This is an issue with SubForms since day one of Financials. now with the release of 2009, I seriously doubt that this issue will ever be addressed.
You will need to rethink the logic. Basically and code to manipulate data and cursors in a SubForm is very complex to make work. The effort to make it work will be more than the value of the functionality.
http://www.mibuso.com/forum/viewtopic.php?f=23&t=26946
Technical Consultant, MS Dynamics NAV
IF Status = Status::Open
THEN BEGIN
SalesLine.RESET;
SalesLine.SETRANGE(SalesLine."Document Type","Document Type");
SalesLine.SETRANGE(SalesLine."Document No.","No.");
IF SalesLine.FIND('+') <<If lines exist it add the new line to the end!
THEN BEGIN
SalesLine."Line No." := SalesLine."Line No." + 10000;
SalesLine.Type := SalesLine.Type::Item;
SalesLine.VALIDATE(SalesLine."No.", 'E87360001');
SalesLine.VALIDATE(SalesLine.Quantity, 1);
SalesLine.INSERT;
CurrForm.SalesLines.FORM.InsertExtendedText(TRUE);
END ELSE BEGIN <<Else it makes it the first line
SalesLine."Line No." := SalesLine."Line No." + 10000;
SalesLine.Type := SalesLine.Type::Item;
SalesLine.VALIDATE(SalesLine."No.", 'E87360001');
SalesLine.VALIDATE(SalesLine.Quantity, 1);
SalesLine.INSERT;
CurrForm.SalesLines.FORM.InsertExtendedText(TRUE);
END;
END
ELSE BEGIN
MESSAGE('Sales order %1 must be Open!',"No.");
END;
I got this to work by copying the exact ONPUSH code from the Insert Extended Text function.
Mine was CurrForm.SalesLines.FORM.InsertExtendedText(TRUE);
One other way would be to copy the InsertExtendedText Function from the the Sales Header to the Sales line form too.
We've modified our insert Extended Text to only happen on "release" of the order by adding
CurrForm.SalesLines.FORM.InsertExtendedText(TRUE); to the menu item release OnPush
KIne's Post above says you need to probably do another find so perhaps after the insert do the find again????
SalesLine.RESET;
SalesLine.SETRANGE(SalesLine."Document Type","Document Type");
SalesLine.SETRANGE(SalesLine."Document No.","No.");
IF SalesLine.FIND('+') THEN BEGIN
CurrForm.SalesLines.FORM.InsertExtendedText(TRUE);
My thought is if they are two different functions both usually run seperately from different menu items ONPUSH
You should be able to take the code from the InsertExtendedText function ONPUSH and add it to this new function ONPUSH and it should still run.
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org