I have a simple project to creating a PO from SALES Order screen. Dynamics SL already has that feature , but it creates a linked PO. So I need to customize SO and PO screen so that lines from SO are simply copied to grid of PO screen with "goods for inventory" as line type. I have run into several issues trying to use Object Model for this:
1. I am able to launch the PO screen using Launch command and pass sales order number as a parmeter.
2. The PO screen opens and retrieves the lines from SOLINE based on this paramter , but when I issue the command
sivMyApp.Controls("cpurchtype") = "Goods for Inventory"
I get the error Error 5046 Invalid Memory Array Handle Passed to Kernel - Object Model
This error does not occur if I invoke the PO screen directly from menu and press a button to auto-insert a line in the grid. Aparently the sivMyApp object does not get initialized with new screen when it is called with "launch" method.
I tried to replace my Launch command on SO screen with startappandautomate but that does not allow interactive user to input other fields on PO and save it. Then I also tried to use setobjectvalue calls instead of sivmyapp calls on PO screen to insert lines in grid, but it disables the Qty column and creates (actualy saves) bad data in Purchase order detail table. Apparently the setobjectvalue for first colunm in the grid (purchase type) causes swimapi to disable the order qty.
Any help will be appreciated.
Thanks.
*This post is locked for comments