Scripting

  • 1.  Have a button script that creates a new SO Line if

    Posted 05-21-2013 16:07
    Have a button script that creates a new SO Line if the customer has a positive balance in Customer UDF loyalty credits. Script prompts for an amount and misc chg (/loyaltycredit) line is added for the negative amount. The field UDF Balance and UDF Used need to be updated too on the customer, so that they can track how much of the credit has been taken and what's available (and reverse, if the line is deleted off SO or SO invoice). What do I do to update a Customer UDF from SO Line entry? Tried a bunch off stuff, but I think I need to call a BusObject to write it, maybe?


  • 2.  RE: Have a button script that creates a new SO Line if

    Posted 05-21-2013 23:31
      |   view attached
    There are several challenges actually. One is I'm assuming you are prompting for the Loyalty Amt to apply via an InputBox and thus have the button set to Execute On Client. But that makes it not possible to run object scripts that could update the Customer UDFs. They require Execute on Server. Another issue is you have separate events going on. The deletion of a Line to reverse update the customer UDFs is really disjointed from the button click that adds the misc line. Here is how I might pursue it to address the issues. This involves total of 3 scripts and a bit of a process change. I attached what I think the button script could look like (No 3 below) 1. Create a Post-Validate on CustomerNo script to get the value of UDF_BALANCE and UDF_USED from Customer Maint. Then set those values into equivalent SO Hdr UDFs with the same name. This way it shows up right on the S/O Entry screen as soon as the CustomerNo is selected. Side note these UDFs should be set as disabled in Customizer so it can't manually be changed. 2. S/O Entry person is now seeing the Balanced and Used right on the order. They manually enter the Loyalty Amt to Apply as a UDF (it's another S/O Hdr UDF). IOW they are no longer being prompted for the amt. 3. They click the button (script) next to Loyalty Amt to Apply. This scripts verifies the Balance > 0 and Loyalty Amt to Apply > 0. Then it adds the misc charge line then it updates the Balance and Used in AR_Customer 4. Create a Pre-Delete or Post-Delete script on SO Sales Order Detail. It's purpose is to check on the line just deleted if itemcode = ""/LOYALTYDISCOUNT"" and then reverse update the Balance and Used in AR_Customer

    Attachment(s)



  • 3.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 04:48
    OMG, with posts like this, Alnoor is going to corner the market on the collective minds.......


  • 4.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 05:04
    Going to?


  • 5.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 05:05
    What's going to really blow you away is when you realize we are all rejected figments of his imagination.


  • 6.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 08:32
    Or he is a figment of our imaginations??? Can he really exist?


  • 7.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 08:43
    Well, he does post at strange times. Perhaps he only exists in the wee hours of the morning.


  • 8.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 08:46
    Yes how did you know I spend most of my day playing Bejeweled and Words with Friends? Shhhhh .....


  • 9.  RE: Have a button script that creates a new SO Line if

    Posted 05-22-2013 10:41
    Wow @AlnoorCassim the script(s) is/are absolutely great! I did wonder if the InputBox was going to cause an issue and obviously it does. As this entry of the loyalty credit is limited to supervisors, I'll hid these fields on the non-supervisor screens. I'm going to load it and test, I can't thank you enough for your very detailed response and of course, as with all your posts, the clear, insightful explanations that enrich and deepen all of our knowledge. Your are very generous.


  • 10.  RE: Have a button script that creates a new SO Line if

    Posted 06-05-2013 13:53
    @MoiraGoggin You may think about putting some sort of logic and a semaphore UDF on the Customer record to serialize their orders so that you do double dip their balance if simultaneous orders could ever be entered for the same customer.