Link to home
Start Free TrialLog in
Avatar of jlblanke
jlblanke

asked on

OnChange Event code is not copying in the fields

Hi Experts,

This is a secondary post from an earlier post. I thought it might be less confusing to start a new post for a new problem.

For some reason the attached code is not copying in the fields. I have used similar code on other entities and it has always works. Why doesn’t it work now?

I do not have Visual Studio installed so it makes it hard for me to see if I’ve missed something. I am not getting any errors either with the OnChange Event or with the save.

Thanks for your help. :)
function-ChangeInspectionSite-re.txt
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi jblanke,

Check line 280

catch (e) { };

Open in new window


if there is an error this statement will hide it. This is bad programming practice. replace it with

catch (e) { alert(e.message)};

Open in new window


and run the code. Let me know if you get any error message this time.

Regards,
Chinmay.
Avatar of jlblanke
jlblanke

ASKER

I made the change. I am getting a 'retrieveParentCustomer' error on change.
Hi jblanke,

I will need more than that to figure out what is wrong. Kindly share the exact error message please.

Regards,
Chinmay.
Here is the error. It is what I was getting on the previous post. I have attached the code.

There was an error with this field's customized event.

Field:customerid
Event: onchange
Error: Object doesn't support property or method 'retrieveCustomer'.
function-ChangeInspectionSite-re.txt
I modified the script (attached). If I  open an existing record and change the field I no longer get any errors. The script removes the old data from the fields; BUT, the new data IS NOT populating in the fields.

If I open a new record and change the field I get the following error:

     There was an eror with this field's customized event.
     Field: customerid
     Event: onchange
     Error: Object doesn't support property or method 'retrieveCustomer'.

Please help. My boss wants this working today and I am unsure of how to proceed because I cannot see where my error is.
modified-function-ChangeInspecti.txt
Hi jblanke,

Sorry I will not be able to look into this matter till Saturday. I suggest you use a javascript debugger or at least start using any one of the IDEs I suggested earlier.

Regards,
Chinmay.
Thanks Chinmay. I'll check into those. I'll look forward to hearing from you this weekend. :)
In the mean time, try to learn how to debug JavaScript.
Unfortunately I do not have any software tools to help with the debugging. If I get an error which points to a specific line then I manually count the lines of code until I get to the error. You have been very helpful in showing me what to look for when I have been getting some of the errors.

This is a most puzzling problem.

I made some corrections to the script. I am now not getting any errors when I change the field, but I also am not getting the data to update the fields. I will continue to plug away. My manager has given me a brief reprieve, but I know he is looking for results.

I will continue to plug away. . . . :)
Well, here's an update. I got the code to populate the fields, but when I do a save, the data in the fields go away.

Any thoughts? I have attached my revised code.
revised-code.txt
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Cool!  I did the Internet Explorer F12 debugger. It did not show any breakpoints. I am really stymied on this because the code works on other forms.
Not sure what exactly happened. But the code is working now. When I change the field value the subsequent fields are updated. When I save the form (or do a save and close) the new data remains in the fields.

Is is possible that there is a delay between the updates I make and the server refresh?

Thanks for being so patient with me.
Thank you for your patience in working with me through this unusual problem. The 'icing' you provided was invaluable and has given me a tool to use on all of my coding problems. It is worth the excellent rating and score.

:)
Hi jblanke,

First of all super thanks for nice words :).

Actually I don't have patience :P so I try to make people independent.. :D and I think in this case it worked out perfectly.

Now to the questions:
- Let me know if you need help with debugging via Dev Tools.
- Yes. It is very important to understand concept of local caching in Browsers. Browsers, by design cache most of the stuff you see on websites(notice most of ) so it is a good chance that Scripts are cached as well so it is a good practice to always clean your browser cache when you are developing Scripts.
 - Also with CRM always remember to Save and Publish your changes :) It can be a culprit sometimes.

Regards,
Chinmay.