Net at Work is hiring!
Grow your career with us.   Apply Now X
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
      Software & Vendor Selection
      ERP Implementation Services
      ERP Migration Services
      Acumatica
      NetSuite
      Sage X3
      Sage Intacct
      SDMO
      Sage 100 ERP
      Sage 300 ERP
      Sage 500 ERP
      CRM
      Strategic Advisory Services
      CRM Training Camp
      Creatio
      Sage CRM
      Employee Experience
      Sage HRMS
      Rippling
      Workforce Go
      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 Sage Hosting
      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
      Sage Fixed Assets
      Vertex SMB Sales and Use Tax
      Prime Foodservice Software
      Rental 360
  • Industries
    • Industries
      Chemicals
      Construction
      Discrete Manufacturing
      Field Service
      Food & Beverage
      Healthcare
      Industrial Manufacturing & Equipment
      Medical Devices
      Nonprofit
      Private Equity
      Retail
      Wholesale Distribution
  • Learning Center
    • Online Resources
      Recorded Webinars
      Whitepapers
      Ebooks
      Success Stories
      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

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
  • This field is for validation purposes and should be left unchanged.
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

    Supercharge Sage 100 with Fortis Payments
    October 8 | 2pm ET
    Register Here

    Year End CRM Evaluation: 2025 Platform Comparison Guide
    October 8 | 2pm ET
    Register Here

    Stop Microsoft 365 Attacks Before They Hit
    October 14 | 2pm ET
    Register Here

    Popular Recorded Webinars

    The Case for Hosting Sage 100 in the Cloud

    What’s New in Sage 100 v2025

    Unified Employee Self-Service Portal, Integrated Seamlessly with Sage 100

    Actionable Tips to Improve AP & AR Process for Sage 100

    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
    • Software & Vendor Selection
    • ERP Implementation Services
    • ERP Migration Services
    • Cloud ERP
    • CRM
    • Employee Experience
    • ECM
    • Nonprofit Solutions

    Learning Center

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

    Infrastructure Solutions

    • Managed IT Services
    • Fractional CIO & Advisory Services
    • Cloud Services
    • Cloud at Work Sage Hosting

    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
    • Prime Foodservice Software
    • Rental 360
    • SDMO

    Industries

    • Chemicals
    • Construction
    • Discrete Manufacturing
    • Field Service
    • Food & Beverage
    • Healthcare
    • Industrial Manufacturing & Equipment
    • Medical Devices
    • Nonprofit
    • Private Equity
    • Wholesale Distribution
    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


    Our website uses cookies to ensure you get the best experience. Learn more.

    I Understand