Updating the purchase line from the result of a lookup

CharlehCharleh Member Posts: 44
I have a routine that allows users to modify the base quantity on the purchase line, which then pops up a form that allows them to select a unit of measure that deals with the outstanding overflow on the balance -

for instance if a user selects a UOM with 128 base units in, and then enters 132 base units instead of 128 into a purchase line, the form will pop up letting them know there are 4 units of overflow. They can then pick a UOM to fit this quantity or create a new one -

The problem I come across is updating the purchase line after the user has clicked the OK button on the form. I've called the form as a lookup using the SETRECORD method to lock the form to the current purchase line - if I modify the purchase line before the form closes, the purchase order form gives an error saying

'Another user has modified the purchase line record etc' and the form does not show the new lines until I open it again.

I want to create a new line with the new UOM and quantity

Line no, UOM Code, Qty, Base Qty
10000, BOX128, 1, 128

user changes Base Qty to 132 (132 - 128 = 4) and then chooses that the new UOM is PCS so a new line should appear with

20000, PCS, 4, 1

I can't figure out the best way of doing this..

I've thought about making a function in which you pass all the parameters to add a new purchase line, but this just seems pointless... too much code for such a small thing

The code that calls the form is in the Purchase Line table like so:
    .... some error checking code 

    // Call form with current purch line
    FitQtyInUOMForm.SETRECORD(Rec);
    
    // Check form result
    IF FitQtyInUOMForm.RUNMODAL() = ACTION::LookupOK THEN BEGIN
       ... need to insert new purchase line here
    END;

I'm starting to not like Navision because so many things seem to have to be done in a backwards kind of way

Anyone have any suggestions as to how to get the right data into the purchase line after I've run the lookup?
Charleh
Sign In or Register to comment.