An entity Custom Field gets converted to date when set from rules or scripts

I have created a simple “Samples” entity with a string Custom Field named Field

I can add a new entity with “123-456” as value for the Custom Field by clicking on “Add Entity” on the Entities window

imagen

If I try to create an entity using rules, actions or scritps the “123-456” gets transformed into a date value


So, if I click “Add Entity” at Entities and I enter a value for the Custom Field, this value goes directly into the database. While setting this value from actions, rules, and scripts seems to undergo a different process

I have played with the attributes of the Custom Field (Mask Type, Editting Format, Default Value, etc.) but they do not seem to be related to the problem

I have SambaPOS 5.3.0

Odd, doing some work on scripts at the minute which uses the api entity helpers for entity data and havnt noticed this…

Run a few tests, does say just 123 do it?
If you set the string in the script rather than input var does it do it.

Yes, setting the string in the script rather than passing it as parameter also leads to a value converted to date

imagen

If I set a value like “abc” then there is no problem. The only problem is with strings that have numbers and the “-” character which SambaPOS may be converting to dates automatically

Try to force the data type:

var field_value = String(field_value);

or

var newFieldValue = String(field_value);
api.Entity(id).Data("Field").Update(newFieldValue);

For both cases the string still gets converted to a date:

Hmm. I was thinking maybe it was converting to date based on the the sum of the numbers but nothing matches up to the Julian Date for what gets saved.

Okay, so the backend is calculating based on the Julian date.

111-111 turns into 5/3/2020

Today’s Julian Date is 176. The Julian Date for 5/3 is 65. 176-65 = 111

It seems only the int in front of the minus sign is used.

1 Like

@Memo WTF, where did that come from.

Guess we know what your hobby is lol :crescent_moon: :star2: :sun_with_face:

Maybe I’m just ignorant, had to Google it lol

4 Likes

How odd… wonder why?

What type is the field set to?

From his original post, it’s a String

1 Like

Perhaps set it to number

Date finds its way as the final value no matter what Field Type is specified. Something, somewhere is subtracting days from the current date and returning that result.

I have tried and the result is the same:

imagen

This issue persists and only seems to occur when using the API and does not occur when manually created within the desktop application.

image
turns into
image

this is caused by DateFuncParser.Parse() at Samba.Domain.Models.Entities.Entity.SetCustomData()

Could someone please look into this? Please and thank you.

1 Like