SUN 2019 – IDO Ext. Class Lab Instructions

Welcome!

Thanks for being a part of my lab for IDO Extension Classes. Today we’re going to do something perhaps a little low key, but that’s mainly because of how limited our time will be. These instructions will be available right here after the conference, so that you can use this as a launch-point to build your own Extension classes.

On Wednesday, we will be covering more details on what you can do with these. If you can’t make it, my slides for that presentation will be available as well.

The Infor provided documentation is all in C#, so I am doing this in VB.NET for those who are more comfortable in that language. If you prefer C#, you can get most of this in that language from the IDO Development Guide.

The Goal

In this project, we are going to create a simple “Standard Method.” This means that instead of returning a collection of data, we will simply be taking some parameters, doing some things, and then returning an integer to state whether or not we were successful.

In this case, the goal is to take a username and amount, then go check the user’s po req limit and return whether or not the amount is above that req limit. By writing this code in an IDO Extension Class, we will be able to access this method from anywhere in the system. From a form, from an Application Event, or even invoked from an external .NET application.

Create Project

  1. Open Visual Studio 2017
  2. Go to File > New > Project
  3. Create a new Class Library
    1. Installed > Visual Basic > Windows Desktop > Class Library
    2. IMPORTANT! You want .NET Framework
    3. You do not want .NET Standard
    4. You do not want .NET Core
  4. Name it SUN2019
    1. Make sure you are using .NET Framework 4.7.2
      1. Important! At home, make sure you target the same .NET framework as your SyteLine version.

Import References

  1. In the Solution Explorer, right click References and select Add Reference
  2. Click Browse
  3. Navigate to your SyteLine installation
    1. For CSI10: C:\Program Files\Infor\CSI
  4. Add the following libraries to your project:
    1. IDOBase.dll
    2. IDOCore.dll
    3. IDOProtocol.dll
    4. MGShared.dll
    5. WSEnums.dll
  5. Click OK

Create “AssemblyInformation.vb”

The following file helps the Mongoose framework understand the library it is importing. You will see this in action at the end of the lesson.

  1. Right Click the SUN2019 Project > Add > New Item
  2. Select Code File from the list.
  3. Change the name of the file to AssemblyInformation.vb
  4. Add the following code:
<Assembly: Mongoose.IDO.IDOExtensionClassAssembly("SUN2019")>

Create the Class File

  1. Right Click Class1.vb and rename it to SUN2019.vb
  2. Visual Studio will ask you if you’d like to change your class name. Say yes.
  3. Copy the following code into your SUN2019.vb file. You may type it if you’re feeling adventurous, but copying it is likely to reduce typos and compile errors.
  4. I will talk about what each section does in my presentation, so that it’s clear what I’m trying to do.
Option Explicit On
Option Strict On
Imports Mongoose.IDO
Imports Mongoose.IDO.Protocol

<IDOExtensionClass("SUN2019")>
Public Class SUN2019
    Inherits IDOExtensionClass
    ' Add Methods Here
    <IDOMethod(MethodFlags.None, "Infobar")>
    Public Function ValidateUserReqLimits(ByVal UserName As String _
    , ByVal Amount As Decimal, ByRef Infobar As String) As Integer
        ' Use context to load IDO data 
        ' in this case the PO Req Limit.
        Dim UserLoadResponse As LoadCollectionResponseData
        UserLoadResponse = Context.Commands.LoadCollection(
            "SLUserNames", "UserLocalPreqLimit", String.Format(
            "Username={0}", UserName), "Username", 1)

        Dim ReqLimit As Decimal
        ' You must check to see if the value is null. 
        ' GetValue will break if the value Is null.
        If UserLoadResponse.Items.Count > 0 AndAlso
            Not UserLoadResponse(0, "UserLocalPreqLimit").IsNull Then
            ReqLimit = UserLoadResponse(
                0, "UserLocalPreqLimit").GetValue(Of Decimal)
        Else
            Infobar = "User has no req limit."
            Return 16
        End If

        ' Check to make sure the amount requested is 
        ' below the user's requisition limit.
        If Amount <= ReqLimit Then
            Infobar = "SUCCESS"
            Return 0
        Else
            Infobar = "FAILED: Amount is over the user's req limit."
            Return 16
        End If

    End Function
End Class

Save and Compile!

  1. Save your project.
  2. Leave the project configuration dropdown in Debug mode.
  3. Go to Build > Build Solution
  4. Wait for the solution to successfully build.
  5. In the Solution Explorer, right click the SUN2019 project and select Open Folder in File Explorer.
  6. Navigate to the bin > Debug folder.
  7. You should see a SUN2019.dll and SUN2019.pdb file.
    1. Take note of where these files are located.

Upload Custom Load Method to SyteLine

  1. Open up the Local instance of SyteLine.
  2. Sign in as sa.
    1. Log into Demo LA – The name will likely be different on the demo machine.
  3. Open the IDO Extension Class Assemblies form.
    1. In versions prior to CSI 10.0.0.308 this is called IDO Custom Assemblies
  4. Press F3 to cancel your filter, and create a new row.
  5. Fill in the following information:
    1. Assembly Name: SUN2019
    2. Import Assembly: Browse to the SUN2019.dll file.
    3. Import Symbols: Browse to the SUN2019.pdb file.
  6. Save the record.
  7. Go to View > User Preferences and ensure Unload IDO Metadata With Forms is checked.
  8. Go to Form > Definition > Unload All Global Form Objects.

Create an IDO

We’re going to create a Dummy IDO on AccessAs, because it will be the fastest way to generate a place to put the IDO Method. We will use it only as a backbone for the IDO, we won’t actually do anything with the data.

  1. Open IDO Projects
  2. Press F3 to cancel your filter, and create a new row.
  3. Fill in the following information:
    1. Project Name: SUN2019
  4. Save
  5. Click New IDO
  6. Fill in the following information
    1. Project Name: SUN2019
    2. Primary Base Table: AccessAs
    3. Table Alias: AA
      1. (We’re not using the table anyway, so it doesn’t really matter.)
    4. IDO Name: SUN2019
  7. Click Next.
  8. Click Finish.

Yes, that is probably the fastest (and ugliest) way to make an IDO. Let’s set up our method!

Create an IDO Method

  1. The IDOs form should have opened automatically after creating your new IDO. You may need to select it.
  2. Set the following information on the IDOs form:
    1. IDO Assembly Name: SUN2019
    2. Ext Class Name: SUN2019
    3. Ext Class Namespace: SUN2019
  3. Save!
  4. For good measure, discard your IDO cache again.
    1. Go to Form > Definition > Unload All Global Form Objects.
  5. Click the Methods button
  6. Click New Method
  7. Change the Method Type to Handcoded – Standard Method
  8. Cross your fingers and hit the drop-down for Method Name
    1. You should see the method ValidateUserReqLimits” in the dropdown. If you see an empty drop down, STOP. That means something isn’t working.
    2. Check to make sure your IDO Cache is fully discarded (and the unload IDO Metadata with Forms checkbox is checked.)
    3. Make sure you’re using consistent names throughout. If something is spelled incorrectly, it will fail.
  9. Select ValidateUserReqLimits from the drop-down.
  10. You should now see the Method on the IDO Methods form, and if it all worked correctly, all of your parameters should be filled in automagically!
    1. This is the benefit of having all those attributes in the IDO.
    2. Scroll the Parameters sub-grid to the right. Notice your Infobar parameter has been marked as a “Message” parameter.

Create a Form to Test

  1. You can never unload your IDO cache enough times. Do it again.
    1. CTRL+U if you’re one of those fancy keyboard shortcut people.
  2. Go ahead and Window > Close All
  3. Launch Edit Mode.
    1. CTRL+E, because I am one of those fancy keyboard shortcut people.
  4. Change your scope to Site Default
  5. Launch the New Form Wizard
    1. Create a New Form
    2. Next
  6. Fill in the New Form Wizard.
    1. Name: You guessed it, SUN2019
    2. Form Type: Build from Scratch
    3. Next
      1. Yup, no datasource. This is a standard method only.
  7. Unclick Save Template, and Finish.

Wire up your Form

  1. Drag a ComboBox field onto the form.
  2. Drag an Edit field onto the form.
  3. Select the ComboBox and set Data Source > Binding to variables.UserName
  4. Select the … details button on List Source
  5. Fill out the Edit List Source Specification form.
    1. Type: IDO Collection
    2. IDO: SLUserNames
    3. Properties: Username, UserLocalPreqLimit
    4. Columns To Display: 1,2
  6. Select the Edit field and set Data Source > Binding to variables.Amount
  7. Drag a Button onto the form.
  8. Select the Button and switch to the Events tab.
  9. Select the … details button on the Primary event.
  10. Click New
  11. Fill in the Event Handler Properties
    1. Name the Event ValidateUserReqLimits
    2. Change Response > Type to Method Call
    3. Select the … details button on Parameters
    4. Click Type Specific Parameters
    5. Fill in the Edit Method Call form.
      1. IDO: SUN2019
      2. Method: ValidateUserReqLimits
      3. Click the Parameter button
      4. WOAH! That was cool, right?
      5. Almost done. Change UserName to FV(UserName) and Amount to V(Amount)
      6. Click OK
    6. Fill out the Event Handler Parameters form.
    7. Set Error Message to mBackEndMessage
    8. Set Success Message to mBackEndMessage
    9. Click OK to close Event Handler Parameters
    10. Click OK to close Event Handler Properties
    11. Click OK to close Event Handlers
  12. Save the form
  13. Exit Edit Mode
  14. Exit the form

Testing the IDO Extension Class

  1. Reopen the SUN2019 form.
  2. Select a user from the dropdown. Preferably one with a Requisition limit greater than 0.
    1. Take note of the Req Limit, and paste it in the Edit field.
  3. Click the Button.
    1. You should get a message saying “SUCCESS”
  4. Change the Amount to a higher number.
  5. Click the Button
    1. You should get a message saying “FAILED: Amount is over the user’s req limit.”

That’s It!

Enjoy the rest of the presentation, and please be sure to come back Wednesday as we talk in detail about what you can do with your newfound power (and some things that you may want to watch out for!)



2 thoughts on “SUN 2019 – IDO Ext. Class Lab Instructions

Leave a reply to michaelmullen Cancel reply