Scripting

  • 1.  I created a script that changes the email address

    Posted 03-17-2015 10:36
    I created a script that changes the email address in Sales Order Entry, header tab, to the contact selected in the Confirm To. However, it only works when I manually pick the contact. I tried adding another one that pulls the same data when the Customer # is entered & the Confirm To drops in, but it doesn't work. The default program places the Company Email, now it puts a blank one. I could get it to look at the default Contact & pull that email, but depending on the Ship To, its not always the default that is in that field once the customer is selected. I want it to look at the field & place the correct email, but I have tried many things without success. Any direction would be appreciated...thanks!


  • 2.  RE: I created a script that changes the email address

    Posted 03-17-2015 11:57
    Where in S/O Entry Header you ideally like your script to fire off and retrieve the email from the Customer Contact OR are you trying to retrieve it from the Ship To (address info)?


  • 3.  RE: I created a script that changes the email address

    Posted 03-18-2015 09:35
    I originally thought when the Customer # is entered, it would fill the Confirm To & I should be able to read that field to update the email address. But, if the Ship To is changed, & it changes the Confirm To, I would also want the email address to change to the new Confirm To. I just always want the email address to match the Confirm To person's email. One of the struggles is also that Confirm To name is on SO Header, not the Contact Code, so I don't have the full key.


  • 4.  RE: I created a script that changes the email address

    Posted 03-18-2015 11:26
      |   view attached
    A lot of concepts for intermediate level scripting class here. What you thought was straightforward and reasonable request to align the ConfirmTo is a bit of a PITA. If we can assume there will always be a ShipTo code entered, whether it's defaulted in when the Customer is selected OR when the ShipTo code is manually changed, AND as long as the ShipTo record has the Confirm To filled in (you can have a separate script run on Pre-Write to enforce that), then you can in fact pull the Email out of AR_CustomerContact table. I've attached a button example of exactly just that (create the button on the Header panel). Life is better this way if there is always a ShipTo. Note: What makes it work is the ConfirmTo in the Ship To is the Contact KEY not the Contact Name. However on the SO Header it's the Contact Name so you don't have the full key. Ergo you could do it an alternate way by sending the Div, Cust No to AR_CustomerContact table then set SetBrowseFilter(), then MoveFirst() then match the Contact Name string and if no match then MoveNext() all in a loop until you find it, BUT I'm hoping you can always go through the Ship To which is better. You can look to see how I created the multi-part key to get to SO_ShipToAddress_svc and the multi-part key for AR_CustomerContact_svc. The general rule of thumb is all key segments except the last have to be null padded. You may want to set Debug_Flag = 1 so you can see more stuff going on. Also you should view this in Notepad++ or similar so you can see the syntax highlighting and colors. The other issue you have to deal with is the event. Since sometimes the ShipCode is defaulted in from the customer and sometimes it's selected, you need 2 scripts for both events (Post-Val of CustomerNo and Post-Val of ShipToCode). However you may just be able to use the same script for both. Another option is tie the script to Table Pre-Write of the Header. IOW when Accept button is pressed, script fires off, gets the email, stuffs it in the order, order closes on the screen, done. Another option is to use a button script

    Attachment(s)



  • 5.  RE: I created a script that changes the email address

    Posted 03-24-2015 10:24
    Thank you @AlnoorCassim , I will try these suggestions!