We have been working on this mobile error for a while, you know the type, really descriptive.

Dynamics CRM Mobile Error customized event

There was an error with this field's customized event.
Field: nothing there
Event: nothing there
Error: Script error

Okay. So it is somewhere in the script. Appreciate the narrowing down.

The error occurred only on the iPhone when loading the opportunity form or when creating or updating items in a custom product entity being used in a sub-grid on the opportunity form. We were able to narrow it down to a script created to update a custom estimated revenue field on the opportunity but that was as far as we could get. We could not make major modifications to the script because the web client users enjoyed the benefits of a previous performance and functionality update we had done. We were not getting the error when testing the mobile client on the Surface but we were not getting a consistently correct total either.

Finally the low tech "alerts in the code" method was employed in an attempt to figure out where the choke point was. Things like alert("Inside the new_TotalAmt here"); and alert("Just figured out the total. Next we are going to the GetProds func"); so we could see where the mobile app was choking. An interesting level of complication was added when comparing the alerts on the web client to the ones on the mobile to see where it was having an issue. We had to take pictures of the mobile alerts and then view them backwards because the mobile client produces them without stopping whereas the web client goes through one at a time, only moving to the next alert on clicking Ok to the current alert.

We finally got enough alerts in there to narrow down where the issue was, a piece of script that was comparing the total calculated in the script with two fields on the form. Well that was something. First we checked to make sure the fields referenced were spelled correctly, check. But as anyone who has dabbled in JavaScript knows, the field has to be on the form in order to be called out in the JavaScript. Well let's double check just to be safe. Yep, there they were on the form, one was the out of the box estimated revenue field, long abandoned but still required to be on the form. We had discovered in a previous mobile adventure it had to not only be available to the mobile client but also Visible. On. The. Form! BAD WORD!

We checked to see if the second field was on the form, it was. Then we checked if it was available to the mobile client, it was NOT, and we checked if it was visible, it was NOT. We updated the field and moved it to our Admin tab on the form. A useful area at the bottom of any form suitable for any field not needed by the typical user but invaluable when troubleshooting.

With cautious optimism we downloaded the customizations to the mobile client, opened an opportunity, got… only alerts! Once we took the alerts away the custom code worked like a champion and everyone did their happy dance.

So the moral of this story - make sure all fields needed by your mobile client are:
     1. On the form
     2. Set to Visible by Default
     3. Set to Available on the phone

Field Settings

If you pay attention to these three thing, you will save yourself a lot of time and heart ache. Maybe the heart ache is just me, but definitely a lot of time.