Point of Sales. Part 2: how to (Auto Update / sync field from Library1 to Library2) without make a new entry

169 views
Skip to first unread message

Sinar Raya

unread,
Dec 27, 2019, 5:42:03 AM12/27/19
to mementodatabase
Halo Mementos.

here my 2nd Forum post.
i try to make POS (Point of Sale) / CRM / Similar app using memento database.

as we alrdy solved about Auto fill new entry from Lib1 to Lib2

now im stuck on Auto Update / sync field from Library1 to Library2 without make a new entry on Liblary2

Example:
we have 2 Library= Inn & Out

Screenshot_20191227-142430_Memento Database.jpg



each Library with field =
- Name
- Pic
- BarCode
- Qty in

Screenshot_20191227-160815_Memento Database.jpg



Lets said i have 3pcs Ferrari at Library Inn, now i need to update it became 5pcs
when i  update Qty in at Library Inn / or in case i forgote to fill Qty in when make new entry (Ferrari)
it will really Precision if Library Out also get sync / Update  on its Ferrari Qty Out = 5pcs

when i put this Script again (Trigger 2 = Updating an entry - Before saving the entry)

e = entry(),
o = libByName("Out");

newo = new Object();

//newo [] = e.field("");

newo["Name"]=e.field("Name");
newo["Pic"]=e.field("Pic").join();
newo["BarCode"]=e.field("Barcode");
newo["Qty in"]=e.field("Qty in");

o.create(newo); 

& many other Script im read from google....
i got Result = Library Inn Update, but Library Out not Update / sync, else it make new entry (or nothing change or script error) as the result.
so here i am... 
pls share any clue / knowladge how to make it possible to sync / Update some field / whole field from Library1 to Library2 without mess entry inside one / both Library (NO = make new entry / delete)

simple said, i try to implement CRUD function (Creat, Read, Update & Delete) on my memento Library.
with this few Function (if we implement it into right way) mementodatabase can become AWESOME all in 1 Database / POS / CRM app at our Pocket

Gilles Mons

unread,
Dec 27, 2019, 10:48:10 AM12/27/19
to mementodatabase
Hello Sinar
yes it is possible it is necessary to use the auto filling

I let you search a little after I will give you the solution

Er Mo

unread,
Dec 27, 2019, 12:04:59 PM12/27/19
to mementodatabase
Bei eine Neuen Eintrag wird der einfach an das Ende der Biebliothek geschriben .Beim ändern eines Eintrages muss der Eintrag gesucht werden um ihn  ändern zu können . Mann braucht also 2 verschietene Skripte .

Hi there
With a new entry, it is simply written at the end of the library. When changing an entry, the entry must be searched to be able to change it. So you need 2 different scripts.

Sinar Raya

unread,
Dec 27, 2019, 1:06:32 PM12/27/19
to mementodatabase


Pada Jumat, 27 Desember 2019 22.48.10 UTC+7, Gilles Mons menulis:


Thanks Giles & Er Mo
i just search & using methode from here 

and i do implement with  Library Inn as =
AUTOFILL - By title - Entries - Name - copy data = Inn - Name > Name & so on

Screenshot_20191228-003433_Memento Database.jpg

but nothing change at Library Out when i do edit on Library Inn
im also do it at opposite way (make AUTOFILL inside Library Out) but also not work., is there something i miss?

Sinar Raya

unread,
Dec 27, 2019, 1:26:15 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 00.04.59 UTC+7, Er Mo menulis: 


 
Yes Er Mo, i try various script from wiki & mozila, but i keep got error when i try to run that scrip.

i must admit its hard for me to understand javascript Language, so im a bit slowly to learn it.

Er Mo

unread,
Dec 27, 2019, 2:07:33 PM12/27/19
to mementodatabase
 Hallo
Das Skript muss in Bibliothek " Inn " bei Änderung " . Es wird " Pic ,BarCode und Qty in " überschriben . Der Name bleibt gleich . Ich gehe davon aus , wenn sich der Name ändern sollte ein NEUER eintrag gemacht wird . Habe es nicht getestet . Melde dich wenn es Fehler macht .

Hi there
The script must be in the library "Inn" if changed ". It will be overwritten" Pic, BarCode and Qty in ". The name remains the same. I assume if the name changes there will be a NEW entry. Have not tested it Let me know if it makes mistakes.

// Von INN nach OUT
var e=entry()
var name = e.field("Name");
var pic = e.field("Pic");
var barcode = e.field("BarCode");
var qtyin = e.field("Qty in");
// In Datei schreiben
var libclients = libByName ("Out"); //Datenbank aufrufen
var entries = libclients.entries("Name"); // alle daten holen
var entry = entries[0];
var l = entries.length;   // L ist die anzahl der Daten
for (var j=0;j<l;j++){
var sdaten = entries[j].field("Name")
if(sdaten == name){
entries[j].set("Pci",pci);
entries[j].set("BarCode",barcode);
entries[j].set("Qty in",qtyin);

Gilles Mons

unread,
Dec 27, 2019, 2:08:58 PM12/27/19
to Sinar Raya, mementodatabase
Ok Sinar....

1 : un Inn database

Auto fill -> + -> by title -> Javascript  -> choose the "name" field

2 : script 

anotherLib = libByName("Out"); 

entries = anotherLib.find(query + "*");
resultArray = [];
 
for(i in entries )

object = {};

object["name"] = entries[i].field("name");

object["Pic"] = entries[i].field("Pic");

object["title"] = entries[i].title;

object["Barcode"] = entries[i].field("BarCode");

object["Qtty In"] = entries[i].field("Qtty In");

resultArray.push(object);

};


try alone to do the rest if not i will help you


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/20ab5f6a-cd33-4e06-9bbc-b0a05ffa14e7%40googlegroups.com.
Screenshot_20191228-003433_Memento Database.jpg

Sinar Raya

unread,
Dec 27, 2019, 2:22:28 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.07.33 UTC+7, Er Mo menulis:
 

Script error: missing } compound.

When im edit abit became = 

var e=entry()
var name = e.field("Name");
var pic = e.field("Pic");
var barcode = e.field("BarCode");
var qtyin = e.field("Qty in");
// In Datei schreiben
var libclients = libByName ("Out"); //Datenbank aufrufen
var entries = libclients.entries("Name"); // alle daten holen 
var entry = entries[0];
var l = entries.length;   // L ist die anzahl der Daten
for (var j=0;j<l;j++){
var sdaten = entries[j].field("Name")
if(sdaten == name)}
entries[j].set("Pic",pic);
entries[j].set("BarCode",barcode);
entries[j].set("Qty in",qtyin); 

Script error: syntax error 
 

Sinar Raya

unread,
Dec 27, 2019, 2:24:55 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.08.58 UTC+7, Gilles Mons menulis:
Ok Sinar....

1 : un Inn database

Auto fill -> + -> by title -> Javascript  -> choose the "name" field


Thanks Gilles, i try it ASAP.
i will post the result  

Gilles Mons

unread,
Dec 27, 2019, 2:27:35 PM12/27/19
to Sinar Raya, mementodatabase
Try my code...


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Gilles Mons

unread,
Dec 27, 2019, 2:39:39 PM12/27/19
to Sinar Raya, mementodatabase
One error in my script...

object["Qty in"] = entries[i].field("Qty in");


Not "Qtty In"...

After see picture ....


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
Screenshot_20191227-203548_Memento Database.jpg

Sinar Raya

unread,
Dec 27, 2019, 2:41:50 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.27.35 UTC+7, Gilles Mons menulis:
Try my code...



i do creating an autocompletion rule = Name - Name. BarCode - BarCode. and so on

Screenshot_20191228-023433_Memento Database.jpg

but Library Out not change / Update. 
did i do wrong put this autocompletion rule

Screenshot_20191228-024030_Memento Database.jpg


Gilles Mons

unread,
Dec 27, 2019, 2:43:16 PM12/27/19
to Sinar Raya, mementodatabase
Wait step by step....

Mons Gilles
3bis Rue Massena
06500 Menton
06 64 45 94 84
atlas...@free.fr
atlasfr...@gmail.com

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Sinar Raya

unread,
Dec 27, 2019, 2:46:30 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.39.39 UTC+7, Gilles Mons menulis:
One error in my script...



yes Gilles, notice it to, just a bit wrong typo. so i change it alrdy.

this the script im use that show result as my last post = 
anotherLib = libByName("Out"); 

entries = anotherLib.find(query + "*");
resultArray = [];
 
for(i in entries )
object = {};

object["Name"] = entries[i].field("Name");

object["Pic"] = entries[i].field("Pic");

object["title"] = entries[i].title;

object["Barcode"] = entries[i].field("BarCode");

object["Qty In"] = entries[i].field("Qty In");

resultArray.push(object);

 

Er Mo

unread,
Dec 27, 2019, 2:46:51 PM12/27/19
to mementodatabase
Hallo
Sie müssen bei der Bibliothek " Inn " unter Berechtigungen für Trigger  / Verfügbare Sammlungen die Bibliothek " Out " auswählen . Dann darf " Inn " in "Out" arbeiten .
Ps: Bedenken sie den Zeitunterschiet . ich Wohne in Österreich / Europa

Hi there
You must select the "Out" library in the "Inn" library under Permissions for Trigger / Available Collections. Then "Inn" can work in "Out".
Ps: Consider the time difference. I live in Austria / Europe

Gilles Mons

unread,
Dec 27, 2019, 2:54:00 PM12/27/19
to Sinar Raya, mementodatabase
Now you add 2 field text "I.D."
1 in "Inn" base
And 
1 in "Out" base.....

And add in script one "Inn" base:

var o = libByName("Out"),

id = e.field("I.D.");
oEntry = o.findById(id); //search an entry in Spp by ID

if (oEntry != null) 

oEntry.trash(); //delete the entry

{

And the reste of script....

}



--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Sinar Raya

unread,
Dec 27, 2019, 2:54:53 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.43.16 UTC+7, Gilles Mons menulis:
Wait step by step....


Sure Gilles.

  • Hii Er Mo
  • Hi there
    You must select the "Out" library in the "Inn" library under Permissions for Trigger / Available Collections. Then "Inn" can work in "Out".
  • Yes, Permission alrdy turn On / Check when i try that script  
  • result = Script error: missing } compound.& syntax error

Gilles Mons

unread,
Dec 27, 2019, 2:59:46 PM12/27/19
to Sinar Raya, mementodatabase
Sorry "I.D." in Out is not necessary


Mons Gilles
3bis Rue Massena
06500 Menton
06 64 45 94 84
atlas...@free.fr
atlasfr...@gmail.com
--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Er Mo

unread,
Dec 27, 2019, 3:00:20 PM12/27/19
to mementodatabase
Hallo
Welche Zeile ?

Hi there
Which line?

Sinar Raya

unread,
Dec 27, 2019, 3:15:45 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.54.00 UTC+7, Gilles Mons menulis:
Now you add 2 field text "I.D."


if i not fill the I.D, still nothing change  Gilles.

but if i fill it it came error like this = 

Screenshot_20191228-031332_Memento Database.jpg


Sinar Raya

unread,
Dec 27, 2019, 3:22:30 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 02.59.46 UTC+7, Gilles Mons menulis:
 

 heres the detail = AUTOFILL - By title - Input field= I.D 

Screenshot_20191228-031216_Memento Database.jpg


Gilles, is this autocompletion rule alrdy Right? Name to Name, BarCode to Barcode & so on..

Screenshot_20191228-031229_Memento Database.jpg


Er Mo

unread,
Dec 27, 2019, 3:25:54 PM12/27/19
to mementodatabase
Hallo
Kannst du ein Bild von Skript einstellen . Zeile 1

Hi there
Can you post a picture of script. line 1

Gilles Mons

unread,
Dec 27, 2019, 3:32:23 PM12/27/19
to Sinar Raya, mementodatabase
No autofill is by name ... not by I.D.


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Sinar Raya

unread,
Dec 27, 2019, 3:45:01 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 03.32.23 UTC+7, Gilles Mons menulis:
 
result = syntax error shows up everytime i try typing on Name Field

this the script = 

var o = libByName("Out"),

id = e.field("I.D.");
oEntry = o.findById(id); //search an entry in Spp by ID

if (oEntry != null) 

oEntry.trash(); //delete the entry

{

anotherLib = libByName("Out"); 

entries = anotherLib.find(query + "*");
resultArray = [];
 
for(i in entries )
}
object = {};

object["Name"] = entries[i].field("Name");

object["Pic"] = entries[i].field("Pic");

object["title"] = entries[i].title;

object["Barcode"] = entries[i].field("BarCode");

object["Qty In"] = entries[i].field("Qty In");

resultArray.push(object);

Screenshot_20191228-034035_Memento Database.jpg


 

Gilles Mons

unread,
Dec 27, 2019, 3:52:08 PM12/27/19
to Sinar Raya, mementodatabase

Otherwise I will answer you only in private


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.

Sinar Raya

unread,
Dec 27, 2019, 4:06:45 PM12/27/19
to mementodatabase


Pada Sabtu, 28 Desember 2019 03.52.08 UTC+7, Gilles Mons menulis:

Otherwise I will answer you only in private





sure Gilles,  email send alrdy, pls check inbox
Reply all
Reply to author
Forward
0 new messages