
Hi,
I have added a new field to the SOP Entry window which first requires a Customer ID to be entered and if no customer number has been entered I want to clear that field. I am running this script on the BeforeUserChanged of my new field. When I debug and step to the line that clears my field I'm getting an error 1006, which reads 'Unsafe Operation. This operation cannot be performed in the target field's AfterUserChanged, BeforeLostFocus, or AfterLostFocus Events. This operation could compromise the integrity of the application'.
Below is the code I'm running:
If CustomerID = "" Then
MsgBox "Please enter a Customer ID"
SalesTransactionEntry.MyField.Value = ""
Exit Sub
End If
any help would be greatly appreciated.
*This post is locked for comments
I have the same question (0)Hi Rick
Situation:
You attempted to set a field’s value using the field’s AfterUserChanged, BeforeUserChanged or AfterLostFocus events. These events follow the Microsoft Dynamics GP user changed event. Microsoft Dynamics GP uses the user changed event to verify the value in a field; setting the value of the field after the Microsoft Dynamics GP user changed event does not allow the accounting system to verify the field.
Solution:
Set the field’s value using the BeforeGotFocus, AfterGotFocus events. These events precede the Microsoft Dynamics GP user changed event, and allow the accounting system to verify the contents of the field.