Hi everyone,
I wonder if there is a fucntion in NAV that enables me to see if a string is included in another string…
I have a report to create, and the columns to fill depend on the existence of certain sting in the document type…
Yes Poppins, Daniele is right about using STRPOS to locate substrings within strings.
Just a thought though … you mentioned that you want to perform this operation on the Document Type field, and this caused a raised eyebrow for me. In standard NAV, this field is typically defined as an Option data type, not a string. While you can use STRPOS to operate on an Option field, it seems counterintuitive since the list of possible values for the option field is known at runtime. It just seems to me that there are better ways to inspect the value of the field than STRPOS. Add to that the possibility that the actual string value of the option may be edited to something different in Object Designer, thus maintaining the actual stored value of the field but altering the string representation of the value, and consequently representing a potential failure point in code that employs the STRPOS function to inspect the field values. Also using OD, you can add new values to the list of valid values for the Option field, which may introduce new values that comply with your STRPOS function but are not intended to be included in the set you want to process.
STRPOS is a very handy tool for inspecting string values, but probably not the best tool when working with Option data types.
… and one more reason not to use STRPOS to operate on Option fields … multiple languages. Unless the substring expression you’re searching for within the Option field value is multi-language enabled, then your STRPOS test will almost certainly fail if the user is working in a foreign language.