Show/Hide Fields based on a Option field - Dynamics CRM

Hi I am trying to Show/Hide a Field based on the another field that is a two option field. Seems that when the Accounts form loads it correctly hides the field but when i select option "Yes" the hidden field does not reappear.

Sample code given below

function onCreditLimitChange()
{
var creditlimit = Xrm.Page.ui.controls.get("dot_whetherlimitbasedapproval");
if ( creditlimit = false ) {
Xrm.Page.ui.controls.get("dot_limitamount").setVisible(true);
}
else {
Xrm.Page.ui.controls.get("dot_limitamount").setVisible(false);
}
}

Please help.
GulfITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Hi,

Please change your function to below one:

function onCreditLimitChange()
{
var creditlimit = Xrm.Page.getAttribute("dot_whetherlimitbasedapproval").getValue();
if ( creditlimit == false ) {
Xrm.Page.ui.controls.get("dot_limitamount").setVisible(true);
}
else {
Xrm.Page.ui.controls.get("dot_limitamount").setVisible(false);
}
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GulfITAuthor Commented:
Thanks Rikin,

One more help. How do i make the dot_limitamount blank or null when the option is set to false.
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Hi,

Can you tell me if dot_limitamount is an OptionSet or Two Options?
If it is Two Options then you will not be able to make it null... It should be either True or False.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

GulfITAuthor Commented:
its a Currency field.
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
You can set it to 0.00 or 0 only.
0
GulfITAuthor Commented:
Whats the code i need to add for this to make it blank ?
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Xrm.Page.getAttribute("dot_limitamount").setValue(null);

or

Xrm.Page.getAttribute("dot_limitamount").setValue(0);
0
GulfITAuthor Commented:
Done.
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Hi,

Is there any reason to mark the answer and accepting the solution as B? Is there anything missing in my answer?

In my knowledge I have provided perfect answer and I am eligible for all points.
0
GulfITAuthor Commented:
Ohhh sorry i did not mean to do that. Is there anyway i can correct this?
0
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
You can Click on Request Attention button and raise a request to moderator. He will handle the things.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Dynamics

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.