Saturday, September 13, 2014

Resco javascript development - be careful of variable names

We are all new to stuff sometimes and I am currently quite new to Resco.NET and the JavaScript API it has. There is quite a lot of information and examples on Resco's site regarding this but you know how it is when you get going, you're always looking for something that just isn't there. Today I thought I was missing some vital part of how to parse the data, turned out I was addressing the fields incorrectly, so I thought I'd share it with you in case you ever got into the same spot.

Well, my current Customer likes the Resco mobile client a lot. They like the ability it has for configuration and the fact that it is so configurable and even has API:s allowing us to make custom webpages for them that they can take offline, as Resco does support full offline.

Back to my problem, I was trying to show some data from the account entity on the html-page and as I had previously tried this, I had no problems with the name field. However, when I tried retrieving a field that we had created, let's call it "Type" I looked in the list of fields in Woodford as I thought this was their view of the fields and hence how I was to address it. The name it showed was the weird REST-endpoint name with Camel-case "crmk_Type", but I didn't Think to much about this and used it in my code. The result was that I just got "undefined" as the returned value from the Resco JavaScript Bridge. It took me quite some time and a very helpful support guy at Resco before I opened the form editor in Resco and noticed that the field name set there was the normal name, used in the database/soap webservice, "crmk_type". Upon noticing this, I tried the lowercase version and it worked like a charm.

My conclusion is hence that the field names that are to be used in the Resco JavaScript bridge are the lowercase field names, not the Camel case versions, despite the fact that these are the once that you see in the Field list in Woodford. Also, make sure the field that you are addressing has been included in the the field list. This might be changed in the future. If so, I hope to be able to write an update on the subject.

Here is a link to the Support page at Resco.NET where you can download the bridge file and also at the far bottom, go to the reference pages for the Bridge. http://www.resco.net/mobilecrm/support.aspx

Gustaf Westerlund
MVP, CEO and owner at CRM-konsulterna AB
www.crmkonsulterna.se