Detecting "Add" button click
  • coldrick
    Posts:61
    Joined:Wed Mar 12, 2008 10:31 am
    Location:Queensland
    Contact:
    Detecting "Add" button click

    by coldrick » Wed Apr 16, 2008 12:01 am

    In the Customer Screen:

    We want to lock out the Customer account code for users below level 8 (to prevent changes being made), but we want to allow all users the ability to add new customers and assign them a temporary account code.

    Locking is no problem in Screen Builder, and we can unlock using SCRUnlock("CUSCODE"), but how can we detect if the ADD button has been clicked? Or is there another way to approach this? There doesn't seem to be a MODE to detect if a customer is being added, only if a customer has been added.

    Thanks.
  • COBS Tech Support
    Posts:683
    Joined:Fri Sep 09, 2005 8:23 am

    by COBS Tech Support » Wed Apr 16, 2008 8:59 pm

    If you've given a particular user 'add' rights you cannot then prevent that user from adding a record to the system via scripting because there is no 'pre add' event that you can trap. The only thing you could do is display a warning message to explain to the user that any record changes they subsequently make will not be saved to the database. You would then block saving via the save event hook.
  • coldrick
    Posts:61
    Joined:Wed Mar 12, 2008 10:31 am
    Location:Queensland
    Contact:

    by coldrick » Sun May 04, 2008 5:24 pm

    FYI Solution to this problem is as follows. The last bit of code is an extra add-on which copies the billing address details to the delivery address details if the delivery address is left blank (unrelated to the problem above).

    CUSCODE set to show for all security levels in Screen Builder

    In CUSTOMER.MAC...

    If .NOT. Security(8,FALSE)
    SCRHide("CUSCODE")
    Endif

    * Detect adding a customer
    If SCRMode() == 1
    SCRShow("CUSCODE")
    Endif

    * Detect save event
    If Mode == 3

    * We want freight prompt off permanently
    SCRWrite("CUSFREIASK", 'N')

    * We want terms set to 0 if Credit is $0.00
    If SCRRead("CUSCREDIT") = 0
    SCRWrite("CUSTERMS",0)
    Endif

    * Add billing details to delivery details if delivery is blank
    If Empty(SCRRead("CUSDNAME"))
    SCRWrite("CUSDNAME", SCRRead("CUSNAME"))
    SCRWrite("CUSDADD", SCRRead("CUSADDR"))
    SCRWrite("CUSDADD2", SCRRead("CUSADDR2"))
    SCRWrite("CUSDSUB", SCRRead("CUSSUB"))
    SCRWrite("CUSDSTATE", SCRRead("CUSSTATE"))
    SCRWrite("CUSDPOST", SCRRead("CUSPOST"))
    SCRWrite("DELCOUNTRY", SCRRead("CUSCOUNTRY"))
    EndIf

    * Set default to eParcel if no carrier entered
    If Empty(SCRRead("CUSCARRIER"))
    SCRWrite("CUSCARRIER", 'EPARCELSTD')
    Endif

    Return True
    Endif

Who is online

Users browsing this forum: No registered users and 3 guests