NetTalk Central

Author Topic: Max items in an invoice, how to  (Read 6744 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Max items in an invoice, how to
« on: July 30, 2019, 01:56:23 PM »
Hi, I need to limit the number of items inside an invoice.
How to inform the user and avoid it to add a new one?
Im using popups to update
-----------
Regards
Alberto

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: Max items in an invoice, how to
« Reply #1 on: July 30, 2019, 10:06:08 PM »
Probably many ways.

One idea: count the lines in PostInsert and store the result in a sessionvalue. Then set a condition on the insert button based on that value.

Peter

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Max items in an invoice, how to
« Reply #2 on: July 30, 2019, 10:22:38 PM »
This is such a "programmer problem".

So I'm ordering 10 items, but nooo, the software only allows "8 items per invoice". So the user has to create one invoice, then I pay that, then they make a second invoice and I have to deal with that and so on.

Alberto - you're fixing the wrong problem. Don't limit the number of items on the invoice, fix the reason they want to limit it in the first place.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Max items in an invoice, how to
« Reply #3 on: July 31, 2019, 04:22:44 AM »
Bruce, Im saving in a DB thats not of my own and theyve limited the number of items of each invoice, why? I dont know but I cant save more than 22 items for the other system to work ok.
Please I need a way to limit it.
Ive tryed adding code to the preInsert and it does not work, all I could do was add code to the validateall but it only works when the user press save on the 23th item and this is no friendly.
Im using a popup form for the parent an the items browse inside it.
I thnk it will be better to control it in the parent form.
I could hide the Insert button when I enter a form with 22 items but how to hide it while the user is adding items records?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Max items in an invoice, how to
« Reply #4 on: July 31, 2019, 06:30:56 PM »
I guess I would add it in PreInsert.
This is a popup form right?
In PreInsert I'd do a count, and if it's over then send a script to alert the user, and click the cancel button.
But be careful that the original record buffer is restored after the count so that the insert can just continue if necessary.

What code did you try there?

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Max items in an invoice, how to
« Reply #5 on: August 01, 2019, 03:16:59 AM »
Thanks Bruce
In PreINsert Im trying with something like:

Table{prop:sql}='select count(*)......'
Next(Table)
If xxx>22
   loc:invalid='xxx'
   loc:alert='You cant...'
   exit
end

but this code hangs the form
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Max items in an invoice, how to
« Reply #6 on: August 01, 2019, 10:46:14 PM »
probably uou are assuming the table is open, or something like that....

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Max items in an invoice, how to
« Reply #7 on: August 03, 2019, 04:51:36 AM »
No, the table is opened, Ive twicked the web1 example to show you the problem.
Attached goes the app modified just adding an embed in the form.
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Max items in an invoice, how to
« Reply #8 on: August 05, 2019, 11:55:10 PM »
Hi Alberto,

>> and if it's over then send a script to alert the user, and click the cancel button.

seems you missed this bit. There's no scripts to alert the user or click the cancel button that I can see in your code.

cheers
Bruce

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Max items in an invoice, how to
« Reply #9 on: August 05, 2019, 11:59:17 PM »
something like (not tested...)

p_web.popup('too many items')
p_web.script('ntd.cancel();')