Sum of unpaid services

114 views
Skip to first unread message

Amayada

unread,
May 29, 2023, 9:30:47 AM5/29/23
to mementodatabase
Hello everyone, I don't know if my previous post was sent (had a sudden power loss).

Anyway, I'm trying to get the total of unpaid services our clients have with use that I then would like to send to them via SMS.  Sending the SMS is no problem but getting the total seems to be a bother.  Here's my script:

Event : Opening an Entry View card
Phase : After window display

Script :
var e = entry();
var clientLib = lib();
var entries = clientLib.find(e.field("Customer ID Numer"));

for(var i in entries) {
     var paid = entries[i].field("Paid?");
     var salesToday = entries[i].field("Sale for today :");
     var sale = entries[i].field("Sale :");
     var totalUnpaid = sale + saleToday;
     message (totalUnpaid);
     } else {
     cancel ();
     }

I created a dummy account with 4 clients that had services on different dates.  1 of the services is. already paid and each service costs $2.  When I run the script; I get a message that says, 8, then 4 then blinks 4 twice.  The message should just say 6.  Help please?

Er Mo

unread,
May 29, 2023, 3:07:45 PM5/29/23
to mementodatabase
Hallo
Dein Skript weist einige Fehler auf . zB 1 mal Geschwungene Klammer schließen ist zuviel . Weiter weiß ich nicht wie deine Bibliothek aufgebaut ist . Jeder Einkauf ein Eintrag oder im Kunteneintrag die Ausgaben und Einnahmer aufgefürt ?????
Kannst du die Dammi Bibliothek öffentlich zugängig machen und den Link einstellen .

Hello
Your script has some errors. Eg closing curly brackets once is too much. I don't know how your library is structured. Every purchase an entry or in the customer entry the expenses and income listed ?????
Can you make the Dammi library public and post the link.

Ernst

Amayada

unread,
May 29, 2023, 4:07:15 PM5/29/23
to mementodatabase
Hello Ernst!

Here is the link to the dummy library :

Er Mo

unread,
May 30, 2023, 2:00:34 PM5/30/23
to mementodatabase
Hallo
Du musst das kopieren der Bibliothek freigeben , damit ich das Skript bearbeiten kann .Ist in den Einstellungen zu Freigebe

Hello
You have to enable copying of the library so that I can edit the script. Is in the settings to enable

Ernst

Amayada

unread,
May 30, 2023, 3:58:46 PM5/30/23
to mementodatabase
Hello Ernst!

Sorry for that.  I've enabled it.
Screenshot_20230531-035554_Memento Database.png

Amayada

unread,
May 30, 2023, 4:00:24 PM5/30/23
to mementodatabase
I also tried that script but it also doesn't work .. 

Could you help me understand why?

Thank you very much!

Taeke

unread,
May 31, 2023, 9:08:22 AM5/31/23
to mementodatabase
Hello Ernst, 

Can you tell me, where is the "enable copying" option you are talking about?

Op dinsdag 30 mei 2023 om 20:00:34 UTC+2 schreef ernst...@gmail.com:

Bill Crews

unread,
May 31, 2023, 10:56:27 AM5/31/23
to Taeke, mementodatabase
If you scroll down to Cloud Services in the main menu, you'll see under Public Access a form like my 1st attachment. Please make it more like my 2nd attachment, especially checking the Ability to choppy library structure at the bottom of the form.

Please enable any items and levels of access you think people might need in order to help you. If you are sensitive about the library's content, you can copy it first, possibly deleting some or all entries, or you can only selectively allow access.

--
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/5fb03729-be74-498c-82af-f962eb80a0a5n%40googlegroups.com.
Screenshot_20230531_103622_Memento Database.jpg
Screenshot_20230531_103654_Memento Database.jpg

Er Mo

unread,
May 31, 2023, 3:43:11 PM5/31/23
to mementodatabase
Hallo
Wie Bill beschrieb ist für die Handy Version . In der PC Version gibt es Spalten mit diesen Einträgen . Die Spalte für das Kopieren ist Standatmässig LEER ( Nicht zu sehen ) Erst wenn mal im Rechten Bereich der Zelle Klickt , wird das Feld zum Anhacken sichtbar . Ist etwas Versteckt .

Hello
As Bill described is for the mobile version. In the PC version there are columns with these entries. By default, the column for copying is EMPTY (not visible). Only when you click in the right-hand area of the cell does the check box become visible. Is something hidden.

Ernst

Er Mo

unread,
Jun 1, 2023, 3:43:23 PM6/1/23
to mementodatabase
Hallo
Habe mir das Skript mal angeschaut . Ich glaube du vereisst auf ein Feldtyp " Link to entry " . Da habe ich aber keine Bibliothek hinterlegt . Somit komme ich nicht weiter .

Hello
I took a look at the script. I think you insist on a field type "Link to entry". But I don't have a library there. So I can't get any further.

Ernst

Amayada

unread,
Jun 1, 2023, 11:52:29 PM6/1/23
to mementodatabase
Hello Ernst!

I was looking at what you meant and the field I think you are referring to is an autofill entry that's linked to a library that contains the details of the customers.

Amayada

unread,
Jun 2, 2023, 4:36:33 AM6/2/23
to mementodatabase
Hello Ernts!

Thank you for your time.  I can't figure out why the script I posted keeps returning a value of zero so I decided to go another route.  I figured I could try to set up the script to count the number of unpaid services :

Event : Opening an Entry View card
Phase : After window display

Script :

var e = entry();
var clientLib = lib();
var entries = clientLib.find(e.field("Customer ID number"));
var count = 0;

for (var i in entries) {
     var paid = entries[i].field("Paid?");
     if (paid === "No") {
        for(var j = 0; j < paid.length;  j++) {
          count ++;
          }
        }
}
m = count / 2; // I don't know why the count returns a value in factors of 2???

message ("Please be reminded that the customer has " + m + "unpaid services.");


I'm still trying to figure out how to get the sum so I can attach it to the message.

Bill Crews

unread,
Jun 2, 2023, 6:29:09 AM6/2/23
to Amayada, mementodatabase
The length property of a String (Text field) is the number of characters in the string, so if the value is "No", you'll increment count twice. (If the value were "Yes" you'd increment it 3 times.)

Change paid.length to entries.length. You should get what you want.


Er Mo

unread,
Jun 2, 2023, 2:26:53 PM6/2/23
to mementodatabase
Hallo
Ich vermute mal das du in der Anderen Bibliothek für jeden Kunden und jede Buchung einen Eintrag hast . Um die Summe der Offenen Buchungen zu erhalten brauch ich mal die Buchung und ob sie noch Offen ist und das für jeden Kunden . Diese kann man in der Bibliothek mit den Buchungen machen und den Offenen Betrage in dein Dummy Bibliothek schreiben lassen . Oder ich gehe von der Dummy Bibliothek aus , suche für den Kunden die Offenen Beträge , Summire diese und stelle sie auf NICHT Offen um . Beide möglichkeiten haben Vor und Nach Teile . Auch kenne ich deinen Arbeisablauf nicht , wir es am beste zu Integriren ist .

Hello
I assume that you have an entry in the other library for each customer and each booking. In order to get the total of the open bookings, I need the booking and whether it is still open for each customer. You can do this in the library with the bookings and have the open amounts written to your dummy library. Or I start from the dummy library, look for the open amounts for the customer, sum them up and switch them to NOT open. Both options have before and after parts. Also, I don't know your workflow, how it is best to integrate.

Ernst

Amayada

unread,
Jun 3, 2023, 2:24:45 AM6/3/23
to mementodatabase
Hello Bill!

Thanks for that, but I tried it and removed the division factor but the message says "50" instead of "5" ..

Amayada

unread,
Jun 3, 2023, 2:33:15 AM6/3/23
to mementodatabase
Hello Ernts!

Yes, the other library has entries for the customer, customer ID, etc.  The booking made in the main library, the one I copied the Dummy Library from.  The workflow goes from, the customer requesting for a service (it's a shoe cleaning service), then the employee will then enter his / her customer ID in the field which will autofill the details of the customer from the Customer Library.  The employee will then pick the services the customer wants and will give the option to the customer if he / she wants to pay right now or later when he / she comes to pick up his / her shoes.  When the shoes are cleaned, the employee will press the script button to send a message to the customer that the services has been completed.

I'm trying to include the script above into the message to let them know of their unpaid services.

Bill Crews

unread,
Jun 3, 2023, 12:18:36 PM6/3/23
to Amayada, mementodatabase
Since the variable entries contains the results of calling find with the customer (or is it client?) number. Are there really 50 such entries?

It's clear you don't want a count of characters in a string, and if the number of entries in entries is not what you want, then what do you want to count to get the number you want?


Er Mo

unread,
Jun 3, 2023, 2:27:58 PM6/3/23
to mementodatabase
Hallo
Hast du in der Dummy Bibliothek für jeden Auftrag nur 1 Eintrag . Wenn ja könnte ein Berechnungsfeld die Lösung sein . Damit kannst du auf den Betrag für die Verlinkte Dienstleistung zugreifen und dies im Eintrag in einen Eigenen Feld Summieren

Hello
Do you only have 1 entry for each order in the dummy library? If so, a compute field might be the solution. This allows you to access the amount for the linked service and total this in the entry in a custom field

Ernst
Reply all
Reply to author
Forward
0 new messages