03 November 2011

Weekly Dynamic: Complex Web GoTos in SmartLists

Developing for Dynamics GP has covered passing complex parameters through shortcuts in the past. Similarly, I recently had a chance to pass a complex parameter to a web page through a GoTo on a SmartList. I thought I would spend a few minutes showing how this works.

The basic scenario was simple. A client needed to pass an invoice number as a parameter to an internal web page connected to an imaging system. Clicking the GoTo would open a web browser, pass a URL with the embedded parameter and an invoice image would open.

When using SmartList Builder there is a button to create a GoTo. Clicking the button opens the GoTo window. The Plus (+) button creates a new GoTo and one option is to open a webpage. So far so good.

Clicking the Open Webpage option lets you set a description to appear and a enter a URL. To just open a web page, that's all that needs to be setup. Clicking the plus sign allows the assignment of parameters. This useful for sending search strings to say Bing or Google and in our example, an imaging website.

The parameter gets a name that is actually passed as part of the parameter string. The parameter can only be 30 characters long. In addition, you select a table and field from the SmartList to pass. Multiple parameters can be added by clicking plus.

For the first parameter, GP Actually passes the website, a question mark (?) to indicate a parameter, the parameter name, an equal sign and the field value from the select field in the SmartList.

For example, a Bing search for Dynamics GP would look like this:

URL: http://www.bing.com/search
parameter: q
SmartList field value: Dynamics GP

The GoTo would put it together like this: http://www.bing.com/search?q=Dynamics GP

For basic queries this works great, but what if the parameter is more than 30 characters?

What if the parameter you're passing needs to be in the middle of a parameter string?

Don't worry, there's a way around this.

The secret is to create a calculation and pass the calculated result to the GoTo. My client had a very long parameter string with the invoice number at the end so here is what I did:

  1. I grabbed the entire parameter string AFTER the first equal sign (=). I would need that for the parameter later.
  2. Created a calculation in SmartList builder using the calculation button and pasted the parameter string in as a calculation with single quotes around it for SQL.
  3. Then I added a plus sign (+) and selected the invoice number from the available fields at the right. This gave me almost the entire parameter string. The calculation looked like this:
  4. Finally I created a new GoTo with the parameter information before the equal sign as my parameter name and selected the calculated field instead of the invoice number as the field to append to the end.

Everything worked perfectly and now selecting a GoTo from that SmartList reports fires up a web browser and displays the related image.
As we worked with this for a few days we learned a couple of things. The invoice number passed through the calculation could also be passed as a second parameter instead of being embedded in the calculation. The only real benefit is clarity.

Secondly, the SmartList field being passed as a parameter needs to be included as a key field in table. We missed this the first time. The SmartList was built off a single view and didn't need a key field except to satisfy SmartList Builder so Batch Number had been randomly picked as the key field.

Consequently, until we added Invoice Number as a key field, SmartList Builder was passing as parameter an invoice from the batch that included that invoice number, but not necessarily the right invoice number. It was occasionally right and often wrong. Including Invoice Number as a key field in the SmartList solved this problem.

Originally posted by Mark at 11/23/2009 09:00:00 AM