JScript Code in Dynamics CRM to show a Contact’s Parent Account Name on a Case

Thursday, February 24, 2011

For a customer, we needed to show the Contact’s Parent Account (parentcustomerid in CRM) name on the Case form.  Ideally a mapping could be used based on the relationship of a Contact to a Case, but that does not work, at least not in CRM 4.
So, after searching the blogosphere, I used info from these two links to accomplish what we needed:
A quick aside – Richard Knudson’s blog is great!
To do this fix, follow these steps:
  1. In the Case entity, add a new Attribute called Related Account (or similar).  Be sure to note the Name (case_relatedaccount in this case) as this is used in the JScript.
image
  1. Save and Close this, and add the attribute to the Case form.
image
  1. While still on the Form, double-click the Customer field to open its details.
  2. On the Events tab, edit the OnChange event and insert this code:
//check to see that the customer is a contact, not account
if (crmForm.all.customerid.DataValue[0].typename = 'contact')
{
// Prepare variables for a contact to retrieve.
// Get the contact GUID
var contactid = crmForm.all.customerid.DataValue[0].id;
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>parentcustomerid</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
// alert(msg);
}
// Display the retrieved value.
else
{
//alert(resultXml.selectSingleNode("//q1:parentcustomerid").nodeTypedValue);
// this returns the Parent Account GUID
var accountid = resultXml.selectSingleNode("//q1:parentcustomerid").nodeTypedValue;
// }
//now get the account name using the accountid from above
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+accountid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
// alert(msg);
}
// Display the retrieved value.
else
{
//alert(resultXml.selectSingleNode("//q1:name").nodeTypedValue);
//var accountid = resultXml.selectSingleNode("//q1:parentcustomerid").nodeTypedValue;
// set the related account value
crmForm.all.case_relatedaccount.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;
}
// close the else from getting the parentcustomerid
}
// close the main if statement when checking for typename
}
image

Save the changes and publish and test!  It should fill in the Related Account field with the contact’s parent customer name.
I still need to implement some more checking on things, but it does work as intended.

SME Business Software from the ground up

Thursday, December 9, 2010

As I was driving home from a client visit tonight, I had a few moments where I thought about businesses and how people expect software to work today.  As an implementer of ERP software for small and medium sized businesses, going to clients is always eye-opening and refreshing and frustrating and interesting and fun all at the same time.  The particular ERP software my company works with has been around for over 20 years, and is written in old languages, with an old-looking interface (once you get past the pretty home page).  The software is often clunky and requires lots of mouse clicks to get things done.  So, I started thinking, back the the beginning of this paragraph, of what people expect nowadays.

Frankly, people expect a lot.  With the advent and popularity of Facebook, Twitter, AJAX, Amazon, Skoreit, Tabblo, Flickr and more, we are used to simple web apps that allow us to accomplish quickly, intuitively, and simply what we want to do.  On Facebook, you see your friends info, like it, comment on it, update your status, search a vast amount of people and groups quickly, all with a minimal number of mouse clicks and without wondering where to go to do it.

So, we expect the same from other software, even though it may not always be possible.  But, people are starting to expect more and more from their applications.  It can be as simple as looking up records and taking actions, modifying reports easily and quickly, or more complex things like quickly updating a group of records or reversing a posted invoice.

I know that business/ERP software is complicated naturally.  It must be in order to accommodate the different ways companies want to do things, need to do things or have to do things.  Some items are taxable on sales, some not.  Some items are taxable on purchases, some not.  Some items are taxable but the customer is not, except when shipping to a certain address.  Of course, sales and purchase taxes are some of the most needlessly complicated options, but the point remains the same.

What people are expecting is an intuitive interface, where adding records is quick and easy, looking them up is quick and easy, and taking action on records is quick and easy.  The interface must be responsive, easy to navigate, and clean.  Related actions must be readily accessible.  For example, adding a new item should be as simple as entering an ID, description, unit of measure, type, class/group.  Pricing setup should follow quickly, and other options, such as related vendors and their pricing, sales pricing, costing, photos or long descriptions, resource planning info, and more.  All of this should be easily accessible, and easy to add.  As you can see, options abound, just for adding an item.  But all of this complexity allows for easier transaction entry, which is the core.

Something I thought about was a sales order.  Using a web-app interface, creating an order should be a snap.  Simply enter a customer, shipping info should default, tax info defaults, order date defaults, price list defaults, perhaps more.  Adding items should be like updating your status on Facebook – item number, qty, price, unit of measure, done  Heck, price and unit of measure should default.  The item is added and displayed right away, and a new item is ready to add.  This is what people expect (at least it’s what they tell me!).

Or, if you are looking up items, you could highlight what you want and click a link/button to create a new sales order, and a dialog asks for the customer to sell to.  Then everything defaults and you quickly have a new order.  Or an old order is easily copied, especially if you are looking at a list of prior orders for that customer.  More and more, it’s the little things like that people are expecting, and I don’t blame them one bit.  If you are looking at a list of old orders, you should be able to select it and click a button to copy it to a new order (or similar, like a right-click).  You should be able to customize your lookups and views of info, and easily take action on the results.  It seems like a lot of CRM software is going this way, but ERP software not so much.  Perhaps the web-bases suites like OpenERP, Netsuite, Intacct and others do much of this, but I have not seen it yet.

So, what would a system like this require?  A very modular, customizable architecture.  The software should be highly customizable, from the text on buttons to the layout of info, to adding new fields to an entity and linking to other entities (much like CRM systems!).  Workflows and auditing and notifications should be built-in.  Voiding or reversing incorrect records should be allowed and straight-forward and audited.  Notifications for everything should be available.  Record lookups should be quick, customizable, and actionable.

That’s just a sampling of what could be done, and should be done.  I’ve seem some systems work towards some of these items.  Some record lookups in xTuple allow actions to be taken easily, which is great and not found in all systems.  They also continue to work on a nice workflow (as in follow these steps) to setup items and perform transactions.

Obviously there would be a lot of work to be done in the back-end and design/logic of the system, but I don’t see why a company couldn’t do it.  I imagine it would be a newer company, not an SAP, Oracle or Microsoft, since those are all tied to legacy software.  Who knows, since I’m just thinking out loud.  But wouldn’t it be nice if ERP software was as easy to use as the newer web apps we are used to?

ERP and Smartphones

Monday, July 12, 2010

As I was sitting up last night at 3am rocking my littlest man to sleep again, a comparison of ERP being similar to a Smartphone popped into my brain.  It always seems my best thoughts happen in the middle of the night, but that’s another topic.  So, what do I mean by ERP as a Smartphone?

My Smartphone can do lots of things, even though it is a pretty basic model compared to what is currently available.  (Even that statement shows similarity – classes of Smartphones, just as there are classes of ERP, depending upon what you need/want and how much you are willing to invest.)  My basic model, out of the box, can surf the web, send and receive email, send and receive text messages, download new ringtones, play a few simple games, change the colors, etc.  All fairly common among Smartphones, and a pretty basic offering which suits my needs fine at this point.  There are two points I want to make here.  First, my  Smartphone does not do everything, nor do I expect it to.  Second, I can gain added functionality by downloading 3rd party apps that work with my phone.

Let’s start with point two above – 3rd party apps.  As Apple taught us, there is nothing wrong with 3rd party applications to enhance your existing phone.  Apple could not and does not want to have an Everything Phone and all that would entail.  They do not have the developer power or desire to do that.  No single company does.  So, by releasing a development kit, and creating a method for others to develop apps and enhance the smartphone experience, their smartphone becomes a jack-of-all-trades phone that almost can do anything and everything desired.  Not everyone needs all the apps available – people desire different things and the app marketplace is where they go to customize their phone as they desire.  This goes back to the first point above.  Apple, Google, HTC, Sprint, AT&T, et al provide the strong core, and virtually anyone in the world provides the enhancements and “wow” apps.

Translating this to ERP is easy, but people still expect their ERP system to be an all-in-one solution.  This is darn near impossible, for many reasons.  Chief among them, in my opinion, is that every organization has different wants/needs/desires, and expect things to work as they want, not as dictated to them.  The sheer amount of flexibility required to accommodate all options would make the software so complex that setup would take eons and require such detailed knowledge of what options affected what other options that an implementation would be outrageously expensive and cumbersome.  Therefore, companies make a strong core, even SAP and Oracle, and then other ISVs add-on industry specific functions or additional “core” functionality.  Selling this, however, is still difficult at times, because people have not stopped thinking of ERP as an all-in-one solution from a single vendor.  But this cannot be the case, and people need to learn that.

If you look at some ERP projects, especially some open-source examples like xTuple and OpenBravo, you will see an app marketplace.  There, anyone can develop an app that enhances the existing functionality.  Granted, developing an app for an ERP system is more complicated that for a Smartphone, but the general idea is the same: create a strong core, have a development kit that can be used to enhance/extend the core, and provide a way for ISVs/developers to monetize those apps and create an environment where the core is background but indispensible.  Think SalesForce with force.com, SugarCRM with Sugar Exchange, even NetSuite and Quickbooks.  Microsoft Dynamics GP does not have a marketplace per se, but does have a robust 3rd party solution directory.

I think ERP will continue to move in this direction, and I think it has to in order to actually live up to its own acronym – Enterprise Resource Planning.  That can entail so many things to so many different people that being able to get the solid core and then enhance it oneself or purchase/install 3rd party apps is the only way this can happen.

The Small Business Web (site)

Wednesday, May 5, 2010

While looking around on the Google Apps Marketplace, and some of the apps available, I stumbled upon The Small Business Web – “A directory of web apps to help small businesses bloom and grow.”

According to the site, “The Small Business Web is a movement to bring together like-minded, customer-obsessed software companies to integrate our respective products and make life easier for small businesses. While there are many products available for small business owners on the Web, the approach we're taking is to use each others APIs to provide a high-level of integration between these applications and create a more seamless experience for our customers.”

There is a lot to like in that statement, and a broad range of available options covered in the statement.  Notice that using APIs is the main method of integration, and some of the apps are integrated with multiple other apps.  For example, some accounting software may be integrated with expense tracking software, CRM software, email marketing software, and project management software.  I think for small businesses that can be both good and bad (like most things in life), but at this point I think the good will often outweigh the bad.

The Good

  • Focused software, so the small business gets software that is very good at what it does.  This is a very key feature, and cannot be understated.  Having an app (and vendor behind it) that focuses on their core is a great way to take advantage of the latest and greatest functionality available.  I have seen deals lost due to a lack of this in a larger, more broad package
  • Integration with other apps provides a simple way to leverage each application’s best-of-breed features
  • Generally free to manageable pricing (usually per user or per month)
  • All web-based software, so the small business owner does not need a server, server management, backup software and hardware, etc.  This can be a huge headache-saver and money-saver!
  • Always using the latest features of the software due to the SaaS model

The Bad

  • Multiple apps means multiple vendors, which means multiple support options, multiple payments to be made each month (although automated billing is probably used), multiple apps to learn and use and grow accustomed to their interfaces
  • Integration may be used loosely, so you may be expecting more than is available
  • You are paying a monthly or per-user fee for the life of the service, which can add up over time (or user counts!)
  • If you are uncomfortable with knowing your data is at someone else’s house, this may not be for you.  I’m not going to harp on this one, because many, if not all, of these companies hosting these services have better data security than a small business would
  • How do you decide which app to use?

I’m sure there are more positives and negatives, and if you have any please leave a comment.  Overall, I really like this idea, and will be attempting to evaluate some of these apps.  Many have a free trial or are free for one user, one project, etc.  I’m going to do my darndest to get some evals up on the blog soon!

xTuple Release 3.5.0

Wednesday, April 7, 2010

I attended a webinar on xTuple's upcoming 3.5.0 release.  One new item I am looking forward to is drop-ship functionality for Purchase Orders.  It ties in very well with Sales Orders, such that when you create a Sales Order line for a drop-shipped item, it can automatically create the PO right then.  When you "receive" the PO, it automatically updates the Sales Order, telling the order that the quantity has shipped, so you can then Invoice the Sales Order.

Version 3.5.0 should be out any day now, followed by 3.5.1 not too long after.  3.5.1 will add a new "Desktop" to the application, with icons that link to a menu option.  This is more along the lines of what Microsoft is doing with their Dynamics ERP software packages - a customizable home page.

There are some other features in the release, such as autocomplete when looking up records, and some features around manufacturing and tooling that will be helpful.  Overall, I am really looking forward to evaluating this software and comparing it to Dynamics GP and others.

Related:
http://ostatic.com/blog/xtuple-expands-erp-software-with-cloud-computing-drop-ship

Open Source ERP Projects Worth Evaluating

Monday, March 29, 2010

This is not meant to be an exhaustive list, by any means.  These are projects that I have played with some, and believe they can work well for small-medium enterprises.  List is in alphabetical order, nothing more is implied by placement.

They each have their strengths and weaknesses.  Each have a free version, some have commercial versions with additional features.  Compiere, Openbravo, OpenERP, and openTaps all have web-based interfaces.  All can run in the cloud (usually Amazon EC2) or will be with new releases soon.  Hosted versions exist as well.

I plan on publishing more details about each as I continue to test and evaluate against other ERP solutions (mainly Dynamics GP), so stay tuned!

Is OpenERP ready for Primetime in the US?

Wednesday, December 9, 2009

I have had a recent email conversation with a gentleman about OpenERP and its readiness for US-based small businesses.  It's an excellent question, and one I am currently evaluating, and have been for a month or two.

OpenERP, if you do not know, is a modular-based ERP software solution that is more of a framework than most ERP solutions I have seen.  It is built on Postgres and Python, two of my favorite things.  The website touts over 300 modules that are available to plug into your OpenERP solution.  It's feature list is large and broad, to say the least, with modules for Document Management, Wiki, Portals, HR, Projects, and more.

I have downloaded and installed OpenERP on Windows and on Linux.  There is a fat client and also a web client with equal functionality (as far as I have seen so far).  There is also a SaaS version called Odoo (http://odoo.com) that is very reasonably priced.  Although the SaaS version does not let you install all the available modules, but it does tell you why it is that way.

So, do I think it's ready for primetime in the US for small businesses?  For the most part, I would say it is.  The price tag of the software itself is unbeatable (free) and the modules and features are solid.  Other packages will do other things better, but not at the price and perhaps not as integrated.

More to come as I keep learning it and evaluating.