Hi all member,
I have a problem when customize the Sale Order.
Look at picture, When I on third line.
After I input No Item, I wanna change Unit Price of first and second sale lines.
I write following code in trigger OnValidate of No. field:
//for first line
tmpSalesLine.SETRANGE(tmpSalesLine."Document Type","Document Type");
tmpSalesLine.SETRANGE(tmpSalesLine."Document No.","Document No.");
tmpSalesLine.SETRANGE(tmpSalesLine."Line No.",10000);
IF tmpSalesLine.FindFirst() THEN
BEGIN
tmpSalesLine."Unit Price":=1000;
tmpSalesLine.MODIFY;
END;
//more for second line
The value of Unit Price on the first line is not change until i click on it. I try some code below :
tmpSalesLine.VALIDATE("Unit Price"); --- everything is not change
CurrForm.UPDATE(); --- error, you can't use form update here
Rec.VALIDATE("Unit Price"); ---everything is not change
I don't know how to refresh this subform to update new value for first and second line
Can anybody help me?
Thanks very much.
Comments
2) Are you sure that the first line have no. 10000? What about deleting the line and creating new one at the end? I will never hardcode such a thing...
3) From where is your code called? This is the critical point...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
1,
2: I sure the line no 10000. (It's just a example. Actually, I will browse all previous sale line and change all the unit price belong to current No Item. for discount purpose)
3. I write that code in trigger of No. field ( OnValidate )
I said that: The value Unit Price of the first line have changed right. So code is right . But it only change when i click on it ( on column Unit Price of first line ).
So I think because of subform is not update the new value. ( I've tried tmpSalesLine.Validate("Unit Price"), but it isn't work)
can anybody help me?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.