Treat Comma and Period as Decimal Separator in Navision Decimal Fields - dynamics-nav

I want to eliminate an error source, often happening in our company. In our country, we use the comma as decimal separator and a valid decimal number looks something like this: 85,32
The problem is, that the users sometimes press the period instead of the comma, because the keys are next to each other on the keyboard and they do not recognize their mistakes. Navision now formats the number entered 85.32 to 8.532,00 what leads to wrong data in our database.
I tried to set the AutoFormatType to 10 and the AutoFormatExpr to something like this <Integer><Point or Comma><Decimals> and I played around with some other values for AutoFormatExpr, but it still does not recognize the period as a valid comma separator. I even tried to format it afterwards at the OnValidate-trigger, but the AutoFormat logics of navision seems to come first and the value is already altered before the OnValidate field triggers gets executed.
I want to setup my page (or a specific decimal field in particular) that, no matter if the user types 85,33 or 85.33, the result should be 85,33.

Substitution way. Create a field on form(page) with SourceExpr of string type then parse it to whatever you like decimal format and save it to the real field.

Related

How does the format mask work in Oracle APEX?

I have just been given an assignment for University on databases where I have to use Oracle APEX. For one of my columns in a report, I need to use a format mask. The format mask I need in the form of AAAA00, where A is any letter and 0 is any number.
Trying to get this to work is an issue though. I've heard the syntax for any number is 9 and I assume it's A for the letter, so wouldn't the format mask be AAAA99?
This is what I tried
I tried using it but didn't succeed. When using the form, you can still input anything. I even tried using one of the default date options for the format mask, and that didn't work either.
Any ideas on what to do?
Oracle APEX Format Mask is only for the Number and Date type objects, you can't format strings using it.
Also, Format Masks are for display only, lets say I have a mask 9G9G9G9 in an Interactive Grid column, it would display numbers like : 3,1,4,1. I could go and edit my cell putting 1337, it won't change until I save my report, it will then format itself in my mask and display my number as 1,3,3,7.
I believe you are trying to restrict your user from giving an input other than in your format, (an input mask), I believe this post could help you achieve what you are trying .

Using text in a column of Date/Time type in access

I have a column in MS Access in which the data could be any of the following:
A date
Text string: "n/a"
Text string: "n/e"
The vast majority of entries will be dates but a very few will need to be these specified text strings. I would like to still be able to perform date calculations on the column. Whats the best datatype to use?
In my opinion the best approach would be to leave the date field as Date/Time and then add another field to indicate the status if the Date/Time field is Null. Something like:
DateField DateStatus
--------- ----------
2014-09-21
n/a
2014-09-23
2014-09-25
n/e
You could use a single Text field, but then any time you wanted to use the field value as a proper Date/Time value you'd have to convert it using CDate(). You would also have the possibility of other junk getting in there, or dates getting entered in different formats (e.g. d/m/yyyy vs. m/d/yyyy). And finally, you would lose the ability to easily determine whether a Date/Time value is in a particular row (which in my approach would simply be ... WHERE DateField IS [NOT] NULL).
I agree with Gord Thompson's answer - mainly because it's so non-intuitive to have, essentially, two completely different types of data in a single column, and because it's going to make validation/data integrity stuff so much harder with little upside - and, as he indicates with the CDate() reference, dates basically only work reliably like dates if they're in a "date/time" field. Microsoft has a page on choosing a data type that explains some of the Access-specific differences in more detail.
I also suggest that you don't actually have a text field for those "comments," since you say there's only a handful of potential options - use a Long Integer and connect back to a separate table with the list of allowable entries. This will allow you to run reports more easily, change the "display text" in one step instead of potentially dozens of times, etc. It also saves a relatively small amount of space per record (long integer = 4 bytes; text = up to 255 bytes.)
You can also do fun data/reporting stuff with that Comment (long integer) field and dates - even combined into ranges, by the way - queries let you use the two different columns to create a single answer. I have a report that's grouped so that you can see stats for everything that's active (by quarter in which they start) plus everything that's pending (with the code indicating who's responsible for watching this record,) plus everything that's not pending but still doesn't have a start date (with the reason code displayed,) plus everything that's expired (by quarter in which they ended.) It looks like each of those things is in a single column in the report, but it's actually like five columns that have been concatenated with the IIf function.
(Almost every argument I can come up with boils down to "this is what relational databases are all about and why they're so awesome.)

How can I enter an e-mail address with a comma in it into a cell?

I'm trying to insert an email address with a comma in it (and it has to be entered that way) and I'm currently stumped on how to properly insert the exact text into this cell.
The e-mail address that needs to be entered as/is:
joe,.E.Blow#someemail.com
What I've tried is work different escape patterns into the code. For example, this...
'''joe'''+','+'''.E.Blow#someemail.com'''
gets entered into the database as...
'joe','E.Blow#someemail.com'
I've tried different combinations with single and double quotes and it can't even get past a simple parse without errors.
What is the best way to go about getting the email address entered as noted above? I know it's something simple but I'm just spinning my wheels here.
the solution is simple:
for example: joe,.E.Blow#someemail.com
SEE FIDDLE

Why won't " (800) 555-1212" fit in a varchar(20) field?

I have a SQL Server phone number field that is defined as varchar(20). A phone number like '800-555-1212' fits with no issue but a phone number like '(800) 555-1212' will cause a "data will be truncated" error. Why would that be?
That example inserts fine into a field defined that way (I ran a test).
You may have some invisible characters adding to the length like tabs and carriage returns.
Or you may have a calculated field (or code in a trigger) that is based on that field (we have a phone_number_stripped field to store just the numerics) that has accounted for stripping out - but not ( or ).
A value could be "like" that value, but be padded with spaces on either end.
Make sure your software handles that case. I recommend allowing the space, but automatically trimming it off.

advice for transforming data gathered from screen scrapers

good day folks,
I have my screen scraper (scrapy) collecting data of property listings on several property websites. They all have several common fields like price, floor area etc. However, like all scraped data, the values for the fields are rather undesirable right now. For instance, in price, I have obvious values like $1,000,000,000, but I also have stuff like $1,000,000,000 Price on Ask and Price on Ask. So currently, I stored all my scraped fields as char in my database.
I would like to transform these string fields in my database from characters to the appropriate type e.g string to int, so I can index them accordingly. Can someone offer me some advice what would be sensible procedure and method to begin transforming the data?
You want to throw away the "Price On Ask" string? Or is that valuable information?
If there is a lot of noise in the data, and it is all of no-interest, I'd run a filter to remove all non-digits.
But, if time allows, I prefer to process the data explicitly with pattern matching (sample code is PHP):
//$price is raw string
$price=str_replace(',','',$price); //Get rid of commas
$price=str_replace('$','',$price); //Get rid of dollar signs
if($price=='Price On Ask')$price=null;
elseif(preg_match('/^\d+$/',$price))$price=(int)$price; //Simple number
elseif(preg_match('/^(\d+) Price On Ask$/i',$price,$parts)){
$price=(int)$parts[1];
}
else{
echo "Unexpected price string: $price\n";
$price=null;
}
I then have the structure to set flags for some of the strings. Also, when a new string appears in the data my script gets noisy and I can decide if it matters or not.
(Note: setting $price to null implies putting a NULL in the database, not a zero.)

Resources