Scope: managed applications, mobile applications, and ordinary applications.
To test the value type of a variable, compare it with the expected type. Don't use other methods to test types.
Correct:
If TypeOf(Ref) = Type("DocumentRef.GoodsServicesReceipt") Then
Incorrect:
If Ref.Metadata().Name = "GoodsServicesReceipt" Then