Thursday, December 31, 2009

MS CRM 3.0 "Expected '}'" and "Object expected" errors

Hello, there :-)

Have you ever encountered this situation? You write some decent, valid JS code, throw it inside a CRM field event box, Save & Close x2, publish, test, BAM!-error?

Well, provided your code is actually correct (no logical, typing or access errors), you should check the next thing. In CRM 3.0 at least (not having a 4.0 box around atm., feel free to test if you're kind enough) if you load a piece of code having its last line using a line comment, you're in for trouble. I was lucky to find that out while debugging a whole page and noticed that the line comment I was using was extended to the rest of the CRM JS code (due to CRM placing the CATCH(e){} part of the TRY{} block right on the same line with the last line of my code). That was causing havoc to the entire page.

So, remember this hint: never leave the last line of code having a line comment ( "//" ) or you're in for trouble :D


4 comentarii:

CSC said...

brains missing @ parsing JS code @ crm if u ask me

Anonymous said...

nice post. thanks.

crmfaq said...

Thanks! it was nice

Anonymous said...

I should digg your post therefore more people are able to look at it, really helpful, I had a tough time finding the results searching on the web, thanks.

- Murk