Entity Account ID wiped after API Create

Hi @emre

I am using this code to test and add Accounts to Entities (standard Customer):

if (!api.Account(aName).Exists()) {
   api.Entity(fPrimary+eCode).CreateAccount(aName) ;
   dlg.ShowMessage("Exit B - Added Account:"+aName+' for '+fPrimary+eCode);

Emre for some reason api,Entity().CreateAccount() fails to attach the Account to the Entity? It creates the Account OK but does not finalize the link.

The dialogue message is successful. The only thing I can think of is the value of eCode is blank in this case?

I need some advise on this as it is causing some issues at our sites. I thought it was random but it seems I can recreate the issue. [EDIT:] Having trouble now repeating it :confounded:

Thanks in Advance.

@emre here is a GIF that shows you the error! Its like 1 in 3 times…

Dumb resolution as had to convert it from a MP4!..

Maybe it works fine but another entity update (for example a custom data update) breaks it. If you have multiple updates on entity it will be a better idea to do it on a single JS update. Updating account with JS but updating another custom field with SambaPOS actions at the same time may lead to issues.

When you encounter such issues it will be a good idea to use a SQL Profiler. That will better visualize how data is updated.

Thanks @emre good tip and I will check it out.

I have noticed it breaks WHEN a ticket has started see in the GIF above when I return the Ticket is still “New”. So I imagine SambaPOS has buffered the record and the update I call in JScript is discarded or overwritten with the buffered Ticket Record. If not ticket is open it works fine.

Only a guess Emre…

@emre I have found this line of code - like a needle in a haystack!

This line of code:

exec sp_executesql N'UPDATE [dbo].[Entities]
SET [LastUpdateTime] = @0, [AccountId] = @1
WHERE ([Id] = @2)
',N'@0 datetime2(7),@1 int,@2 int',@0='2017-05-10 21:35:55.9259911',@1=0,@2=1981

The line @ 1=0 :scream: why are you blanking my Account ID?

So previously through Automation I have Updated using the API an Account ID against this Entity:

exec sp_executesql N'UPDATE [dbo].[Entities]
SET [AccountId] = @0
WHERE ([Id] = @1)
',N'@0 int,@1 int',@0=1411,@1=1981

No you see it, now you don’t. Emre I can only imagine you have an old buffer data in memory and therefore overwrite my Account ID? I see you wish to update timestamp but why Account ID if you just datestamping Entity record?

Can you please advise, thank you.

1 Like

@emre my issue is I cannot close the ticket DURING AUTOMATION no matter what and where I issue a “Close Ticket” Action.

If I could close the Ticket you would not have the opportunity to wipe my Account ID? Have spend hours trying to avoid this :persevere: It is becoming a big issue at our sites…

I would prefer a work around in this version V5.1.60 if possible?

@emre well I am at a loss to try and get around this, I hope you have some suggestions?
I have tried:

A. Refresh Cache;
B. Close Ticket before Automation Return;
C. 1 Automation CMD calling a 2nd Automation CMD for Close Ticket to work;
D. Change Entity Ticket to blank before return.

All did not fool your elusive wipe of my account ID :scream: