ClientType causes Null Reference Exception
Describe the bug Using the ClientType for making client-specific modification causes a null reference exception System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
To Reproduce Steps and to reproduce the behavior: case ClientType of ClientType::Phone: IsPhoneClient := true; else IsPhoneClient := false; end;
Expected behavior Using ClientType is not causing a NullReference Exception
5. Versions:
- AL Language: 3.0.150570
- Business Central: 14.0.42627.0
You need to check case CurrentClientType. The symbol ClientType is just the option type, containing available values, not an instance with a current value that can be checked.
Sure, it should say this instead of crashing the compiler, but it's still invalid code either way.
You need to check
case CurrentClientType. The symbolClientTypeis just the option type, containing available values, not an instance with a current value that can be checked.Sure, it should say this instead of crashing the compiler, but it's still invalid code either way.
Then can you give advice how to use the client Type option?
I just said how, and it's documented.
case CurrentClientType of
ClientType::Phone:
IsPhoneClient := true;
else
IsPhoneClient := false;
end;
simplified:
IsPhoneClient := CurrentClientType = ClientType::Phone;
As Phone client is just showing the first nonsense fields of a list I want to make fields invisible the customer has no use of in his use case (like the status
I just said how.
case CurrentClientType of ClientType::Phone: IsPhoneClient := true; else IsPhoneClient := false; end;simplified:
IsPhoneClient := CurrentClientType = ClientType::Phone;
Ooooooh! Just tooo simple! :-) Thanks very much!
The Phoneclient is just ignoring it. It's not interested in "Visible = false", it's always showing the first five columns of the page, no matter if they are visible or not. But that's something different.
Ugh, that sounds unfortunate. I'm glad to help with the easy bit but know nothing about that ;-)