Dear Experts,
I have created a new entry form where have a field name is "FA Status"...here data is managed through line no. I have added the release and reopen button in ribbon section. I want to update the last "FA status" from this card to Fixed Asset card.
I have write the code in newly customized table field on Validate, but there is no effect. please help me to resolve it.
My code is below.
Fa Status - OnValidate()
IF Status=Status::Released THEN BEGIN
FixedAsset.RESET;
IF FixedAsset.FINDLAST THEN
REPEAT
IF Reco.GET(FixedAsset."Fa Status") THEN
FixedAsset."Fa Status":=Reco."Fa Status";
FixedAsset.MODIFY;
UNTIL FixedAsset.NEXT = 0;
END;
thank you very much....unfortunately I was written my code on wrong places...i need to write the code on
Status - OnValidate().
Resolved,
I have tried with same..but unable to update the FA card - FA Status field. I have attached the screenshot the relation between Fixed Asset table and newly customized table (Reco).
1. in the SETRANGE, Reco.Code as you have written, I guess which was blank.
2. As I mentioned, Get work based on Primary Key, and as per your screenshot, you have declared "type", Code, "Line No.".
So You have to pass the all the 3 values for Get method.
3. you are in the Reco Page then why are you again call the get, directly you can update the last FA value.
IF Status=Status::Released THEN BEGIN FixedAsset.RESET; FixedAsset.SETRANGE("No.", Code); IF FixedAsset.FINDLAST THEN IF FixedAsset."Fa Status" <> "Fa Status" THEN BEGIN FixedAsset."Fa Status":= "Fa Status"; FixedAsset.MODIFY; END; END;
Still if you are not getting the expected result then, Share the Reco and Fixed Asset data, also let us know the link between reco and Fixed Asset.
Thank you for your reply sir. I have updated my code...but still it is not working. I have send the screenshot.
Hello,
Your code is not clear, I do not have your table architecture so I am giving you some suggestions.
GET is working on primary Key.
If you need to update all the records then use below format, it would be more faster than you written.
IF Status=Status::Released THEN BEGIN FixedAsset.RESET; //Also use filter here based on relation between fixedAsset and Your table //You can remove the Repeat until if single record needs to update. IF FixedAsset.FINDSET THEN REPEAT //Your Statement, for example IF Customer.GET('10000') THEN BEGIN Customer.Address := 'New Address 12345'; Customer.Modify(); END; UNTIL FixedAsset.NEXT = 0; END;
What is the primary Key fields of Reco?
Repeat Until is used for get/update set of records based on filter criteria and you have mentioned you want only last record.
rewrite your code by filtering the Fixed Asset records as shown below.
Still if you have doubt then share your Tables fields with relations and some data so that I can check and update.
IF Status=Status::Released THEN BEGIN FixedAsset.RESET; FixedAsset.SETRANGE(LinkField, LinkedValue); IF FixedAsset.FINDLAST THEN BEGIN //Your Statement for example FixedAsset."FA Status" := "FA Status"; FixedAsset.Modify(); END; END;
Sohail Ahmed
874
YUN ZHU
829
Super User 2025 Season 1
Mansi Soni
595