Need Help?
  • Application Remote Support
  • Infrastructure Remote Support
  • Sage HRMS Remote Support
  • Helpdesk
  • General Inquiry
1-800-719-3307
Net at Work Net at Work
  • Solutions & Services
    • ERP/Accounting

      ERP Services
      Acumatica
      NetSuite
      Sage X3
      Sage Intacct
      Sage 100 ERP
      Sage 300 ERP
      Sage 500 ERP

      CRM

      Strategic Advisory Services
      Digital Marketing Solutions
      CRM Training Camp
      Salesforce
      Microsoft Dynamics 365 CRM
      Sage CRM
      Infor CRM (formerly Saleslogix)

      Employer Solutions

      Sage HRMS
      Sage People
      Criterion
      Miviva

      Enterprise Content Management

      Imaging / Scanning
      Document Management
      Workflow Automation
      Solutions

      Nonprofit Solutions

      Abila by Community Brands
      NetSuite
      Sage
      Salesforce

      IT and Security Services

      Managed IT Services
      Fractional CIO Services
      Cloud Services
      Cloud at Work
      DR/Business Continuity Planning
      Compliance & Security
      Storage & Recovery
      Networking
      IT Security Services
      Communications

      Web Solutions

      Services Overview
      B2B Technology Suite
      Magento eCommerce
      WordPress CMS
      Systems Integration
      Website Managed Services
      Online Marketing & SEO
      ERP eCommerce Integration

      Additional Solutions

      Enterprise Business Intelligence
      Avalara Automated Tax Solutions
      Fortis Payments
      LeaseQuery Lease Accounting
      Sage Fixed Assets
      Vertex SMB Sales and Use Tax
  • Industries
    • Industries

      Healthcare
      Chemicals
      Food & Beverage
      Medical Devices
      Nonprofit
  • Learning Center
    • Online Resources

      Recorded Webinars
      Whitepapers
      Ebooks

      Upcoming Events

      Live Webinars
      Seminars
      Virtual Training Courses

      Training Courses

      View all available training course options
  • Company
    • Why Us

      Who We Are
      Management
      Our Partners
      Locations
      Careers

      News

      Press Releases
      Success Stories
      Net at Work Blog

      Contact Us

      1.800.719.3307
      Email Us

      Programs

      Alliance Partnership Program
      Women at Work
      Diversity and Inclusion
  • Blog
  • Contact Us
  • Contact Us

Home » Newsletters » Sage 100 Newsletter – April 2019 » Sage 100 Custom On-Screen Message in Sales Order Entry Part 2

Sage 100 Newsletter – April 2019

Keeping You Up-To-Date With Information About Sage 100

Sage 100 Custom On-Screen Message in Sales Order Entry Part 2

By: Jane Amorim, Business Analyst / Consultant

We’re back for part 2! (Read Part 1)

If you recall, we started coding a handy pop-up notification like the one below:

Now we’re going to take this one step further and have our code check that freight has been entered for customers with a Customer Type of F (found on the Additional tab in Customer Maintenance).

Step 1: Open Custom Office User Defined Script Maintenance.

Step 2: Use the lookup glass to locate your “message_box” script that we created during the first installment.

Step 3: Write the code that will display a message box if freight is 0.  In later steps we’ll also grab the customer type and determine whether that customer needs to be charged freight, but let’s tackle this in phases.

We’ll start with the code below.  I’ll explain what it all does as we go along.  For now, type up the code verbatim into the Script box.  It should look like this:

Now let’s break it down.

We discussed initializing or preparing variables for use in the first installment.  We’ll do that initializing with both the retVal and the Freight variable.  (See first installment for more info on the use of retVal, also.)  We’ll then execute a line of code that grabs the value of the “Freight Amount” field in SO Entry on the Totals tab.  That line of code is retVal = oBusObj.GetValue(“FreightAmt”, Freight).  The GetValue “method”, as it’s called, grabs the value in a data field of your choice which you enclose in double quotes (FreightAmt in this case).  It then places that value into a variable that you can use in your code (the variable Freight).

Next, we must check the value of our Freight variable.  Is it 0?  Or even less than zero, due to a typo, perhaps?  We do this with an If…Then…Else statement.  We’re just going to use the If…Then… part, though.  As with most VBScript stuff, you can find more info online about If…Then…Else statements with a web search.

Our If…Then… statement is going to ask, is the freight amount less than or equal to zero?  That looks like this: if Freight <= 0 then.  If so, we tell Sage to throw an error message on screen and prevent the user from saving the order before the problem is rectified.  We do that with this line of code: retVal = oScript.SetError(“Freight is required for this customer.”)

This error message can say anything you want it to say.  Just change the text enclosed in double quotes.  E.g. retVal = oScript.SetError(“Say something else.”)  Another tidbit, the part after the apostrophe, “throw an error,” is a comment.  You should get into the habit of adding comments to your code.  You do that by using an apostrophe pretty much anywhere and typing out little love notes to yourself and those that come after you.

Finally, because we could add as much code as we need after the if Freight <= 0 then, the End If statement just tells the program we’re done with our If statement.

We actually have a fully functioning script at this point and could test it out as is, but we’re going to take this a step further.

Step 4: Add code to check the customer type (on the Additional tab in Customer Maintenance) and throw an error only for customer type “F.”

The highlighted lines below are the new additions you’ll need to make to your code.  Let’s review them together.

First, we’re prepping a couple of variables for use again.  The oCust variable is a numeric value which we’ll use to store an “object.”  (That’s a program in Sage, like Customer Inquiry.)  The sCustType variable was initialized as a string (text) value and that’s why we have the double quotes ( = “” ), which is an empty string, rather than = 0.  Next, we assign an object (customer info, basically) to the oCust variable with the line: Set oCust = oSession.AsObject(oBusObj.GetChildHandle(“CustomerNo”)).  Because we will be executing this code in Sales Order Entry (see previous installment), we will already have a customer’s data loaded.  This line of code says: Grab the data for this customer (for which we are entering this order).

You saw the GetValue method earlier when we retrieved the Freight Amount.  Now we’ll use it to get the customer’s type.  We do that with: retVal = oCust.GetValue(“CustomerType$”, sCustType).  Note that we’re now calling oCust rather than oBusObj.  If we had called oBusObj and asked it to retrieve the customer type, we would have received no data.  That’s because the customer type is not available on the Sales Order Header, which is what oBusObj is presently pointing to being that we’re running this script in Sales Order Entry.

Finally, we’ll add another If…Then…Else… statement.  We’re checking that the customer type is “F” with the line: if sCustType = “F” then.  Note that we want place this line before the code that grabs the freight amount and checks if it’s <= 0.  Finally, we must wrap it up with another end if.

Step 5: Compile your code.

When you’re done typing out the code, click “Accept” to save the script and close the UDS Maintenance window.  (You must click “Accept”, or your code will not be saved.)  Then click “Compile, “ then “Compile” again in the next screen that opens, and then close any windows remaining open.

Step 6: Test your message box script!

In Customer Maintenance, select a customer to test with.  On the Additional tab, enter “F” in the Customer Type box.

Enter a sales order for your customer and try to save it with $0 in the Freight Amount field.  You should get a message box like the one below and should not be able to save your order.

Congrats!  You are now a scripting initiate!  Stay tuned to future installments so you can use to add to your repertoire!

« Return to Newsletter

In This Issue
  • From the Desk of the Sage 100 Consulting Manager, Lisa Margolies
  • Sage 100 Version 2019 Debut- At a Glance
  • Sage 100 Custom On-Screen Message in Sales Order Entry Part 2
  • DSD Multi-Company Processing Enhancements
  • Featured Consultant – Brett Zimmerman Sage 100 Senior Business Analyst / Consultant
  • Sage 100 Support

    Helpdesk:
    P: 888.494.9479
    E: helpdesk@netatwork.com

    Ready to Upgrade Your
    Sage 100?
    Fill out this form and get your free quote
    Request Upgrade Quote

    Request Sage 100
    Consulting Services

    Get Help From Our Sage 100 Consultants
    Request Services

    Sage 100 Live Webinars

    Journey to Next Generation Financial Management with Sage Intacct
    March 15 | 2pm ET
    Register Here

    Recruiting & Quiet Hiring: What Quiet Quitting / Hiring Means for 2023 & How Technology Can Help
    March 28 | 2pm ET
    Register Here

    Tips for Sage Users to Improve Data-Driven Decision-Making
    March 28 | 2pm ET
    Register Here

    Popular Recorded Webinars

    Sage Cloud Hosting: Moving On-Premise Sage 100 to the Cloud

    Reducing Manual Tasks in Your Sage Accounting & Shipping Processes

    From Pain to Gain: How to Best Approach Your Sage 100 ERP

    Go Digital with DocLink Paperless PLUS for Sage 100

    Building a Sustainable Digital Manufacturing Business

    Sage 100 – Live Online Training Courses

    Wide range of class topics! Browse the course calendar & register.

    Sage 100 Webinar Archive

    View our library of on-demand recorded webinars.

    Refer a friend, get a $100 Gift Card!

    Submit a Referral / Learn More!
    Do you have a friend or colleague whose company might benefit from utilizing a Net at Work service or solution? If so, refer them to us below and receive a $100 gift card or donation to your charity of choice!

    Connect With Us

    Business Applications

    • Overview
    • ERP/Accounting
    • Cloud ERP
    • CRM
    • Employer Solutions
    • ECM
    • Nonprofit Solutions

    Learning Center

    • White Papers & Guides
    • Ebooks
    • Training Courses
    • Virtual Training Courses
    • Success Stories
    • Live Webinars
    • Recorded Webinars
    • Trials

    Infrastructure Solutions

    • Overview
    • Solutions
    • Managed IT Services
    • Fractional CIO & Advisory Services
    • Cloud Services
    • Cloud at Work
    • Compliance & Security
    • DR/Business Continuity

    Support

    • Application Remote Support
    • Infrastructure Remote Support
    • Sage HRMS Remote Support
    • General Inquiry
    • Helpdesk

    Web Development

    • Services Overview
    • Magento eCommerce
    • WordPress CMS
    • Systems Integration
    • Website Managed Services
    • ERP eCommerce Integration

    Company Information

    • Why Us
    • Alliance Partnership Program
    • Women at Work
    • Diversity and Inclusion
    • Partners
    • Careers
    • News
    • Blog
    • Privacy Policy
    • Contact Us

    Additional Solutions

    • Enterprise Business Intelligence
    • Avalara Automated Tax Solutions
    • Fortis Payments
    • LeaseQuery Lease Accounting
    • Sage Fixed Assets (Sage FAS)
    • Vertex SMB Sales and Use Tax

    Industries

    • Healthcare
    • Chemicals
    • Food & Beverage
    • Medical Devices
    • Nonprofit
    Net at Work
    Net at Work (HQ)
    575 8th Ave
    New York, NY 10018

    P: (800) 719-3307
    info@netatwork.com
    Locations Across North America »
    Visit our sister companies:
    Cloud at Work - Sage Application Hosting
    Pixafy - An eCommerce Agency
    Docutrend
    WordPress Image Lightbox Plugin