Sage 300 How to Debug into a Business View from a Sage 300 Web Screen

Introduction

Some developers may already know how to debug into your C/C++ Accpac Business View while debugging/running your module’s Sage 300 Web Screen. But, for those who do not, this little tip is very handy.

This tip allows you to debug into your Accpac Business View (where you have the source) and from your module’s Sage 300 Web Screen.

Debugging in the IDE

You have your solution loaded in the Visual Studio IDE and when you debug, you want to debug all the way down into your C/C++ Accpac Business View.

In your solution, right-click on the Web project and select the Properties menu option:

Blog181

Click on the Web tab page and notice the Native Code checkbox at the bottom in the Debuggers section:

Blog182.png

Select this checkbox and Save the changes.

This will allow you to debug into your native C/C++ code.

Debugging in IIS

The previous section showed how you can debug into native code while debugging your web screen. But, what if you want to debug into native code while your screen is not running in debug (meaning it is running in IIS)?

Launch Visual Studio and be sure to Run as administrator

From the Debug menu, Select Attach to Process…:

Blog183.png

In the Attach to Process popup, be sure to Select the show processes from all users checkbox. Look for the w3wp.exe and Click on it.

There may be multiple w3wp.exe’s listed and it is important to select the correct one. If the user is listed as IIS APPPOOL\…, this is NOT the correct one as it is an IIS executable not running Sage 300.

Blog184

Once the correct w3wp.exe is highlighted, Click on the Select button:

Blog185.png

In the Select Code Type popup, Select the Debug these code types: option and Select the Managed (v4.6, v4.5, v4.0) and Native checkboxes and Select the OK button:

Blog186

This will allow you to debug into your native C/C++ code. 

Summary

This article explained how to debug into native C/C++ code when debugging your Web Screen solution in Visual Studio and also how to attach to an IIS process to debug into native C/C++ code if the Web Screen is running (not in debug mode).

Happy debugging.

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

 

Advertisements

Sage 300 How to Create a Class in Visual Studio from JSON

Introduction

Some developers may already know how to create a class from JSON metadata. But, for those who do not, this little tip is very handy.

I’ll use the Sage 300 Web API and create classes based upon the ARCustomers endpoint. Of course, this also possible with any JSON metadata, but since this is a Sage 300 blog, using Sage 300 metadata feels right.

I give credit for this tip to Vega and I’m simply providing an illustrated example in this article. Thanks Vega!

Sage 300 Web API

The Sage 300 Web API is a great source for JSON metadata since the payloads are JSON. And, since the Web API has implemented the Swagger UI, it is even easier to access the metadata.

The first step is to access the Swagger UI. This is accomplished by navigating to your Sage 300 Web API and accessing the Open Swagger UI button:

Blog161

After the Swagger UI has loaded the endpoints, scroll down to the ARCustomers endpoint and click on it to expand the available actions:

Blog162

Click on the first GET action to expand the UI. In the Model Schema section, you will see the metadata for the ARCustomers payload. Copy this entire section:

Blog163.png

Now, we have the JSON metadata in our buffer. It is time to move onto Visual Studio to create some C# classes based upon this metadata!

Visual Studio

In this example, I will be using Visual Studio 2017 and C#.

Open Visual Studio 2017 and Create a new class called ARCustomers:

Blog164

Before we paste the contents of the buffer, delete the 3 lines for the ARCustomers class, which are indicated by the arrow in the image above:

Blog165

We are now ready to paste our JSON. From the Edit menu, select Paste Special –> Paste JSON As Classes:

Blog166

That’s it! Well, almost. 😊 As you can see, we now have C# classes that follow the hierarchy of the JSON metadata. It is very easy to see the hierarchy as well as all the column names:

Blog167

The Paste Special feature names the top class Rootobject and the first or main class is named value. It makes more sense that they are named ARCustomers and ARCustomer respectively:

Blog168.png

Tip

The arrays should be changed to IList especially when dealing with optional fields.

Summary

This article explained how to create C# classes in Visual Studio 2017 from JSON metadata that was copied from the Sage 300 Web API ARCustomers endpoint.

Any copied JSON metadata can use the Paste Special feature in Visual Studio to create classes based upon the JSON. I used the Sage 300 Web API as an example of metadata that will create several classes based upon the JSON.

Thanks again Vega for the tip!

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

Sage 300 Trouble Installing Visual Basic 6.0 on Windows Server 2012/2016

Introduction

The Sage 300 SDK, not Web SDK, requires Visual Basic 6.0 SP6 to be installed on the computer. But, what happens when that computer has Windows Server 2012/2016 and there are compatibility issues when attempting to install Visual Basic 6.0?

This article will show how to get Visual Basic 6.0 successfully installed.

Solution

While this solution might not work for all, it has worked for Sage 300 developers.

Simply uncheck the Data Access Components option during the installation:

Blog151

That’s it!

References

If more information is required or if the actual steps needed to install Visual Basic 6.0 on Windows Server 2012/2016 (and even Windows 10) are required, please refer to the following links:

https://stackoverflow.com/questions/30656303/vb-6-data-access-component-installation-on-windows-2012-server

http://donovanbrown.com/post/Build-Visual-Basic-60-applications-with-Visual-Studio-Team-Services

https://www.codeproject.com/Articles/1191047/Install-Visual-Studio-on-Windows

Summary

This article explained how to install Visual Basic 6.0 on Windows Server 2012/2016 by unchecking the Data Access Components option.

Reference links are provided if more information is required.

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

Sage 300 How to Return Super View Values from the Process Service

Introduction

So, you are developing Web Screens for Sage 300 and you want to be able to check a field value or some field values that are returned from the super view. In the Sage 300 Desktop, which is based upon the Visual Basic 6.0 development environment, this is simple and straight-forward.

But, how is this done in the Web Screens where the process is handled by a Worker Role?

This article will explain how this is accomplished by looking at our Sage 300 Web Screen Payment Batch Unit of Work (UOW) service implementation as an example.

Process Flow

But, before we begin, let’s briefly review the Web and Worker Roles as they relate to a Process task.

Blog141

The Sage 300 Web Architecture uses both web and worker roles to serve the functionality of the web screens. Worker roles are used for most long running processes, usually indicated by a progress-meter, and some reports.

Blog142

The above diagram illustrates the flow once a process screen submits or starts the process.

Because the super view is handled and processed in the worker role, the business view (which is mapped to an MVC model) is not returned to the web role to access the required values.

Process UOW Service

Blog143.png

The Process UOW Service is the class that invokes the Process Repository where the super view’s Process function is invoked and hydrates a model upon return from the function.

var model = repository.Process(seedEntity.Model);

But, this model is in the worker role and the model is not serialized back to the web role.

Process Result’s ResultObject

The ResultObject in the ProcessResult object will contain the value or values that you will want to return to the web role. But, you must place what you want in this object since we do not serialize the model into this object (hindsight says we should have!).

Prior to Sage 300 2019, the setting of the ResultObject was done by the developer by overriding the Process UOW’s OnExecute base class method. The following routine is from our 2018.2 implementation of the Payment Batch UOW class:

Blog144

While overriding this base class method effectively was able to access and set the ResultObject, it also needlessly had to implement a lot of other code.

Sage 300 2019 eliminated the need to override the OnExecute base class method by providing an override method which provides the ability to set the ResultObject without re-implementing the base class method. The overridden OnExecute was deleted in the Payment Batch UOW class and replaced with an override to the GetResultObject method instead:

Blog145

Back in the Web Role

At the completion of the process, control is returned to the screen’s JavaScript callback function onProcessComplete. If the ResultObject was set in the Process UOW Service’s override method GetResultObject, it is now available in this callback event:

Blog146.png

Summary

This article explained how to return a super view value or values from a process service in the Sage 300 Web Screens.

As indicated in the XML Comments for the GetResultObject virtual method, since this is a single object and not an array or dictionary, if multiple values are required, use the pipe symbol as separator to concatenate multiple fields.

The GetResultObject is a virtual method that can be overridden in the Process UOW service class to return a value or values from the worker role to the web role.

The onProcessComplete JavaScript callback function is invoked at the completion of the process and the ProcessResult.ResultObject is available for the developer with any values that may have been set in the worker role. By default, the ResultObject is null.

So, not as simple as the desktop implementation, but still doable with a few extra steps!

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

 

Sage 300 Compiling Web Screens in Release Mode Tip

Introduction

When developing Web Screens for Sage 300, a developer typically compiles and runs in Debug mode within the Visual Studio IDE.

Changing to Release mode and compiling the solution performs an additional step which is to deploy or copy the required assemblies and files to the developer’s local Sage 300 installation. This is beneficial for the developer to see the screens running via the Sage 300 homepage.

This deployment or copy is performed by the post-build event utility MergeISVProject.

But, the files may be locked by another process. This article will explain who has these files locked and the steps required to successfully compile in Release mode or manually copy files.

Why are my files locked?

Files are targeting the Web folders will be copied without issue, while the files in the Worker folder will most likely be held by our worker service. This service is responsible for managing the worker role for the Sage 300 Web Screens.

This is the reason that a compile in Release mode or a manual copy of files to the Worker folder may not be successful.

Blog131

How do I unlock my files?

Stopping our worker service, compiling in Release mode or copying of files and then re-starting the worker service is the best and simplest way to resolve this issue.

Stop the Worker Service

Invoke the Services Desktop Application and scroll down to the Sage.CNA.WindowsService:

Blog132

Double-Click the service and select Stop:

Blog133

Compile in Release Mode or Manually Copy Files

When the developer solution is compiled in Release mode or files are manually copied, with the Sage.CNA.WindowsService stopped, the copy process will not run into a lock or contention scenario.

Re-start the Worker Service

To re-start the service, select Start:

Blog134

Summary

This article explained why a compile in Release mode or a manual copy of files to the Worker folder for the Sage 300 Web Screens may run into a locked or contention scenario.

The copy process will not encounter an issue if the Sage.CNA.WindowsService is stopped.

And, don’t forget to re-start the service after the compile or copy is successful!

Finally, after any file is updated in either the Web or Worker folders it is always good practice to perform an IIS Reset of the Default Web Site.

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

 

 

Sage 300 2018.2 Web SDK

Introduction

The Sage 300 Web SDK (SDK) is a collection of wizards, utilities, samples and documentation for developing Web Screens for the Sage 300 Application.

This week we released the Sage 300 2018.2 Web SDK to coincide with the release of the Sage 300 2018.2 Application.

It’s Available!

The SDK is available at https://github.com/SageNADev/Sage300-SDK.

Branches

As described in a previous blog and in the README file in the root of the repository, the branches contain the different versions of the SDK.

master

Contains the current version of the SDK (2018.2).

develop

Contains the in-progress version of the SDK (2019).

release-…

Contains the previous versions of the SDK (release-2017, release-2017.1, release-2017.2, release-2018, and release-2018.1)

What’s New

Documentation

Updated documentation is available.

In the docs\upgrades folder is a document for the upgrade procedures for moving partner source from Sage 300 2018.1 to Sage 300 2018.2. This folder also contains documents for explaining the upgrade steps specific to the Bundle Registration class and the Behaviour JavaScript file.

In the docs\development and docs\wizards folders you will find documents pertaining the wizards and tutorials which have been updated to reflect changes regarding to a …Behaviour JavaScript change.

The docs\presentations folder has been updated and includes a PowerPoint presentation for what’s new in the SDK for 2018.2.

In the docs\utilities folder you will find a document for the new Sage300Utilities utility which is used by the Sage 300 UI Wizard during compilation and an updated document for the MergeISVProject utility which has been refactored and enhanced for JavaScript Minification and Partner Deployment folders.

The samples\customization folder has a new folder called Sample4_AR_Invoice_Entry_Customization containing a new sample and document.

Visual Studio 2017

All wizard manifests have been revised to include Visual Studio 2017 as a target IDE.

This means that when registering the wizards, the registration process will prompt you to select the Visual Studio version for the wizard being registered.

Visual Studio 2013 and Visual Studio 2015 are still supported targets and all three versions can be used for Sage 300 Web Screen development.

Blog122

Samples

The previous samples have been updated with new global references and now reference the common AccpacDotNetVersion.props file in the settings folder.

A new sample has been added to the Web SDK. The AR Invoice Entry Customization Sample illustrates the following:

  • Adding a tab control
  • Enhancing the display via CSS
  • Populating a dropdown list
  • Populating a grid with a method in the Finder!
  • Save, Delete, Update, Grid Refresh

Blog123

Solution Wizard

Minor changes to the wizard to support the updated components and references in the Sage 300 web screens.

Customization Wizards

Minor changes to the wizard to support the updated components and references in the Sage 300 web screens.

Code Generation Wizard

Minor changes to the wizard to support the updated components and references in the Sage 300 web screens.

See the Defects Corrected section for information on the resolved defects

Sage 300 Utilities Executable

This is a new utility for 2018.2 which facilitates the building of template files used by the wizards. This is only relevant if the Sage 300 UI Wizard package is compiled in Visual Studio.

MergeISVProject Executable

This utility is a post-build utility used by various wizards and the generated partner solution to pre-compile Razor Views and deploy assets to a local Sage 300 installation for developer testing.

It has been refactored and enhanced in 2018.2:

  • Minify JavaScript files
    • Now your JavaScript files can be minified when delivered to a customer
    • As of 2018.1, Sage 300 JavaScript files are minified
  • Create deployment folders
    • Helpful for when the partner needs to create an installation for a customer
  • New informative messages in the Visual Studio Output Window
    • Easily see what has been created in what deployment folder

New settings folder in the Web SDK

The new settings folder in the Web SDK now contains a common AccpacDotNetVersion.props file that is used by the wizard and sample source instead of every solution having its own version.

A generated solution will still have its own version as it should no longer reference the Web SDK’s version.

Defects Corrected

  • An error will be encountered in the Code Generation Wizard if a column in a partner model is named “EntityName” as this is the name of a public constant in the Model class. A warning message will prevent the code generation until the column name is changed.
  • Finder code generated by the Code Generation Wizard regarding data type and expressions has been simplified and corrected. Additionally, the …Behaviour.js file, on successful return from a finder selection, was not performing a Get to get the record from the repository and instead used the object returned from the finder. The record returned from the finder is out-of-process and needs to be fetched by the screen. Changes to partner code are only required if a partner’s business view has logic regarding a new record which was incorrectly being invoked by an existing record that “looked like” a new record. This has been corrected. The following shows the previous routine from the Source Code Sample and the new routine:

Previous Logic

setFinderData: function () {

var data = sourceCodeUI.finderData;

sg.utls.clearValidations(“frmSourceCode”);

         ko.mapping.fromJS(data, {}, model Data);

sourceCodeUI.finderData = null;

         modelData.UIMode(sg.utls.OperationMode.SAVE);

         sourceCodeUI.sourceCodeModel.isModelDirty.reset();

         sourceCodeUISuccess.setkey();

},

New Logic

setFinderData: function () {

var data = sourceCodeUI.finderData;

sg.utls.clearValidations(“frmSourceCode”);

sourceCodeUI.finderData = null;

sourceCodeRepository.get(data.SourceLedger, sourceCodeUISuccess.get);

},

The Upgrade Wizard includes a step that indicates that this change is optional and MUST be done manually in existing partner Behaviour JavaScript files. Because manual changes may have been made to this routine since it was generated by the Code Generation Wizard, we are unable to automatically make this change via the Upgrade Wizard.

  • A business view property name of “Type” was previously generated by the Code Generation Wizard as {EntityName}Type.cs. This creates an error in our Optional Fields JavaScript implementation. This has been resolved by generating the model property as “Type” but prefixing the property with the namespace to avoid ambiguous references with the System.Type.
  • Corrected issue where the Next step validated credentials for Code Types that do not use credentials

Images for Partner Menus

Sage 300 2018.1 introduced vertical menus for navigation. However, the hardcoded images for partner menus were based upon the position of the partner menu (12 hardcoded images for 12 partner menus). It was not ideal, but all the time we had in 2018.1!

Sage 300 2018.2 has removed the hardcoded images and replaced them with default images that maybe overridden by the partner who wishes to supply their own images.

The {module}MenuDetails.xml has been enhanced with two new elements that are supplied via the Sage 300 UI Wizard. The elements are: IconName and MenuBackGroundImage:

<IconName>ValuedPartner/menuIcon.png</IconName>   <MenuBackGoundImage>ValuedPartner/menuBackGroundImage.jpg</MenuBackGoundImage>

Where ValuedPartner is the name the partner supplied in the UI Wizard

  • The IconName element defaults to the “puzzle piece” image
  • The element value is added as $companynamespace$/menuIcon.png
  • The MenuBackGroundImage defaults to the “discussion” image
  • The element value is added as $companynamespace$/menuBackGroundImage.jpg

Blog124

The MergeISVProject utility is the post-build event utility that deploys your solution to the developer’s local installation of Sage 300 when your solution is in Release Mode. It copies these files (menuIcon.png and MenuBackGroundImage.jpg) from your web project’s Content\Images\Nav folder to the External\Content\Images\Nav\$companynamespace$ folder of your local Sage 300 installation.

Therefore, in your web project’s Content\Images\Nav folder is where your will place your partner images (named menuIcon.png and menuBackGroudImage.jpg) and overwrite the existing files.

Summary

The Sage 300 2018.2 SDK is released and ready to be downloaded!

Documentation updates, the ability to run the wizards in Visual Studio 2017, a new AR Invoice Entry Customization sample, minification of JavaScript files, enhanced deployment folders, and the ability to specify partner images for the vertical menus are all in the Web SDK.

We continue to look forward to addressing the needs and expectations of the Sage partner community and ecosystem.

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.

 

Sage 300 2018.1 Web SDK

Introduction

The Sage 300 Web SDK (SDK) is a collection of wizards, utilities, samples and documentation for developing Web Screens for the Sage 300 Application.

This week we released the Sage 300 2018.1 Web SDK to coincide with the release of the Sage 300 2018.1 Application.

It’s Available!

The SDK is available at https://github.com/SageNADev/Sage300-SDK.

Branches

As described in a previous blog and in the README file in the root of the repository, the branches contain the different versions of the SDK.

master

Contains the current version of the SDK (2018.1).

develop

Contains the in-progress version of the SDK (2018.2).

release-…

Contains the previous versions of the SDK (release-2017, release-2017.1, release-2017.2 and release-2018)

What’s New

Documentation

Updated documentation is available.

In the docs\development folder you will find documents which have updated screenshots in the setup and tutorial documents to reflect the new flow of the Code Generation Wizard.

In the docs\patterns folder you will find a new document for Coding Patterns. At this time, only one pattern is documented, but will soon contain more patterns implemented in the Sage 300 Web Screens.

The docs\presentations folder has been updated and includes a PowerPoint presentation for what’s new in the SDK for 2018.1.

In the docs\templates folder you will find the updated Word Template used by our PDX Content group.

In the docs\upgrades folder is a document for the upgrade procedures for moving partner source from Sage 300 2018 to Sage 300 2018.1. This folder also contains a document for manually upgrading a customization solution’s controller to inherit from our MultitenantControllerBase class instead of Microsoft’s Controller class.

In the docs\wizards folder you will find documents which have updated screenshots to reflect the new flow of the Code Generation Wizard and the new HeaderDetail Code Type.

Visual Studio Code Maps

Visual Studio Code Maps have been provided for specific entities, controllers, utilities and helper classes.

In the maps folder you will find various code maps which can be opened in Visual Studio to see a graph of relationships in specific classes.

Blog11CodeMap

Samples

The previous samples have been updated with new references and minor corrections.

The Receipt sample has been re-factored to use the new base class and implementation for HeaderDetail code type.

Solution Wizard

Numerous changes to the wizard to support the updated components and references in the Sage 300 web screens.

Customization Wizards

Numerous changes to the wizard to support the updated components and references in the Sage 300 web screens.

The Customization Wizard Plugin was modified to generate a controller inheriting from Sage’s MultitenantControllerBase instead of Controller. See the document in the docs\upgrades folder for manual steps.

Code Generation Wizard

Numerous changes to the wizard to support the updated components and references in the Sage 300 web screens.

The new HeaderDetail code type generates enough code to have a functioning header-detail screen that compiles and can be run. However, in this initial offering, a grid (main component of a header-detail screen) is not generated by the wizard. This is being planned for the next release of the SDK!

Blog11Step1

The flow of the wizard has been enhanced to support the new HeaderDetail code type with multiple entities (Accpac Business Views). Information that is relevant to all entities has been moved to the first step.

 

Blog11Step2A tree control has been added to the second step for adding, editing and deleting entities. The tree control displays and allows for hierarchical entities as required by the HeaderDetail code type.

 

Blog11Step2aThe Entity tab of the second step allows selection of the entity and editing of the properties.

Blog11Step2bThe Options tab of the second step allows selection of assorted options.

 

Blog11Step2cThe Properties tab of the second step allows for manual entry of properties for the DynamicQuery and Report code types. It now allows for the modification of property names before the code is generated for the other code types as well.

 

Blog11Step2dThe Compositions tab of the second step is only relevant for the HeaderDetail code type and allows for the compositions of the entity to be included or not. The wizard will generate the composition logic in the CreateBusinessEntities routine of the Repository class.

 

Blog11Step3

The third step has been refactored to display an XML representation of what will be generated by the wizard.

WebApi

A new GL Segments endpoint has been added.

Defects Corrected

The module name for a development partner’s menu item was not being localized when displayed in the window manager. This has been resolved.

An error might be encountered in the Clear Statistics sample. This has been resolved.

Vertical Menus

There are no code or menu changes required for the new Vertical Menus of the Sage 300 web screens. A default icon (colored puzzle image) will be assigned to a partner’s menu item.

In 2018.2, we are modifying this implementation to allow the partner to specify an icon they want to associate with their menu in the menu XML. The partner will then be required to deliver this icon along with the other module assemblies.

Blog11VerticalMenus

Summary

The Sage 300 2018.1 SDK is released and ready to be downloaded!

Documentation Updates, new Visual Studio Code Maps, a new Code Generation Wizard flow along with a new HeaderDetail Code Type, updated Samples, and a new WebApi endpoint are all in the SDK.

We continue to look forward to addressing the needs and expectations of the Sage partner community and ecosystem.

As a standard disclaimer, any topic in this article is subject to review and doesn’t represent a commitment as to when it will be available.