Hello Gomathi, thanks for this video! I tried it out and realized that I get the messages when I change the value in any field in the customer card. How would the code look like in the OnModifyRecord trigger if I want to display the message only when changes are made in the Address field?
the OnModifyRecord trigger can be used to execute custom logic when a record is modified. To display a message only when changes are made in the Address field, you can use the following code trigger OnModifyRecord(): Boolean var RecRef: RecordRef; FieldRef: FieldRef; OldAddress: Text[100]; NewAddress: Text[100]; begin // Get the record reference RecRef.GetTable(Rec); // Get the Address field reference FieldRef := RecRef.Field(FieldNo(Address)); // Get the old and new values of the Address field OldAddress := FieldRef.Value; RecRef.GetRecord(Rec); NewAddress := FieldRef.Value; // Check if the Address field value has changed if OldAddress NewAddress then begin Message('The Address field has been changed.'); end; // Continue with the default behavior of the OnModifyRecord trigger exit(true); end;
To help you troubleshoot this problem, I would suggest checking the following: Ensure that the xRec variable is correctly populated before the page is closed. You can use the Debugger in Business Central to step through your code and verify that the xRec variable contains the expected data. Double-check your onclosepage trigger code for any potential errors or conditions that might prevent it from executing as expected. Make sure that you are properly referencing the xRec variable within the trigger. Check if there are any conflicting triggers or events that might interfere with the onclosepage trigger. Sometimes, other triggers or events can override the expected behavior. Review your page design and layout. Make sure that the xRec data is correctly bound to the page and that the relevant controls are properly configured to display this data.
@@gomstechtalks The extension object 'recxrec' cannot be declared. Another extension for target 'Customer Card' or the target itself is already declared in this module.
Thank you very much
Welcome 😊😊
Hello Gomathi, thanks for this video! I tried it out and realized that I get the messages when I change the value in any field in the customer card. How would the code look like in the OnModifyRecord trigger if I want to display the message only when changes are made in the Address field?
the OnModifyRecord trigger can be used to execute custom logic when a record is modified. To display a message only when changes are made in the Address field, you can use the following code
trigger OnModifyRecord(): Boolean
var
RecRef: RecordRef;
FieldRef: FieldRef;
OldAddress: Text[100];
NewAddress: Text[100];
begin
// Get the record reference
RecRef.GetTable(Rec);
// Get the Address field reference
FieldRef := RecRef.Field(FieldNo(Address));
// Get the old and new values of the Address field
OldAddress := FieldRef.Value;
RecRef.GetRecord(Rec);
NewAddress := FieldRef.Value;
// Check if the Address field value has changed
if OldAddress NewAddress then begin
Message('The Address field has been changed.');
end;
// Continue with the default behavior of the OnModifyRecord trigger
exit(true);
end;
I tried with onclosepage trigger, it is not showing the xRec data. Can you please suggest.
To help you troubleshoot this problem, I would suggest checking the following:
Ensure that the xRec variable is correctly populated before the page is closed. You can use the Debugger in Business Central to step through your code and verify that the xRec variable contains the expected data.
Double-check your onclosepage trigger code for any potential errors or conditions that might prevent it from executing as expected. Make sure that you are properly referencing the xRec variable within the trigger.
Check if there are any conflicting triggers or events that might interfere with the onclosepage trigger. Sometimes, other triggers or events can override the expected behavior.
Review your page design and layout. Make sure that the xRec data is correctly bound to the page and that the relevant controls are properly configured to display this data.
Thank you much much much. Take Care Bye Bye..
Hope you can see HD options👍🏼
@@gomstechtalks 😅😅 nice joke
Need 1080 too. I think your new videos are 1080. Right ?
Yes
mam recxrec is error how it will be removed
Please share the error message.
@@gomstechtalks The extension object 'recxrec' cannot be declared. Another extension for target 'Customer Card' or the target itself is already declared in this module.
thank you mam this is resolved😄