Our customer has the requirement that they should be able to select all items required from that screen before returning to the sales order screen. What I have done so far is to have a flag to indicate which items are to be added upon pressing ok, and the routine that picks up those items (onValidate of No.) is detecting each one sucessfully, but only ever adds the item for which the '->' was on when pressing OK! I realise that if the user selects multiple items by holding the shift key, all of the highlighted items are returned as members of the pointer to the record, but it can be frustrating to release the shift key to see all of the items selected dissapear!
Basically, what I ask is: how do cause a new sales line to be generated automatically for each of the items selected?
Thanks for any input!
0
Comments
Let there be no doubt: you will need to write code to create the functionality you describe. I think *marking* the records (Ctrl+F1) offers users a comfortable way of selecting more than one item, while at the same time providing the developer with an efficient way to see which ones were selected.
Please note that MARK-ing a record takes place *only* on the client, so different users will not get "in each other's way".
Jan Hoek
Product Developer
Mprise Products B.V.
DefDocument function below, and start the SelectMarkedItems() from a menu on the form after the items have been selected. This will then copy all the marked items to the document, inserting them after the last sales line.
DefDocument(NewDocType : 'Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order';NewDocNo : Code[20])
DocType := NewDocType;
DocNo := NewDocNo;
SelectMarkedItems()
Window.OPEN('Copying Item #1################### #2###################### to #3######### #4###########',
"No.",Description,DocType,DocNo);
CurrForm.SETSELECTIONFILTER(Rec);
MARKEDONLY(TRUE);
SalesLine2.SETRANGE("Document Type",DocType);
SalesLine2.SETRANGE("Document No.",DocNo);
IF SalesLine2.FIND('+') THEN
NextLineNo := SalesLine2."Line No."
ELSE
NextLineNo := 0;
IF FIND('-') THEN
REPEAT
NextLineNo += 10000;
SalesLine."Document Type" := DocType;
SalesLine."Document No." := DocNo;
SalesLine."Line No." := NextLineNo;
SalesLine.VALIDATE(SalesLine.Type,SalesLine.Type::Item);
SalesLine.VALIDATE(SalesLine."No.",Rec."No.");
SalesLine.INSERT(TRUE);
Window.UPDATE;
UNTIL NEXT = 0;
CLEARMARKS;
MARKEDONLY(FALSE);
OK, thanks - that makes perfect sense - except for one thing: how do I pass the 'DocType' and 'DocNo' parameters through to the subform? At the moment, I am calling the customer's specialised item list (based on the item table) as a 'Form.RUNMODAL(0,ItemList)' from the Sales Order Form? ](*,)
Thanks!
ItemListSelect.DefDocument("Document Type","No.");
ItemListSelect.RUN;
8)
Thanks for that - all seems to be working now! =D> \:D/ 8)
Sorry to be a pain :oops: - just one thing, although the code to create the sales lines is working, per se, the user needs to do a 'View->Refresh' to see the changes. I've tried putting in CurrForm.UPDATE (with and without a 'FALSE' parameter) in various places (events) on the form, but it always comes up with errors along the lines of "you cannot perform that function here".
What would be the best way of updating the form to reflect the updates, thanks?
My browser has 'View->Refresh', I haven't seen this in Navision. :?:
Actually it should work as stated without any Currform.Update. The user who performs the action should instantly see the new records appear in the sales subform. Only other users on the same sales order need to read the sales header again to see the changes.
Is your customer using SQL or native server ( which version) ? If it is a SQL Server problem I can't help you. The code works without problems on a 3.70B Client and native server.
Maybe this will help :
Clear(ItemListSelect);
ItemListSelect.DefDocument("Document Type","No.");
ItemListSelect.RUN;
Commit;
Currform.update(TRUE);
We're running V4 on a SQL database. Tried doing commits, etc., and gave up. Instead the "Add Multiple Items" Function was added to the Functions menu, and it all works fine now. Thanks anyway.