(Solved) Disable an Advance Search Field

Hi all,

We are customizing out Opportunity Summary Screen and would like to disable an advance search using an on change script.

The script is attached to the oppo_location field and appears to work with standard text fields, but has no effect on an advanced search field.

Example: When oppo_location = UK, then hide advance search field oppo_parentcompany

The script:
if(oppo_location.value=='United Kingdom')
{
oppo_parentcompany.disabled = true;
}
else
{
oppo_parentcompany.disabled = false;
}
Hope you can help.....
EAD
  • 0

    Hi,

    Here's an example of disabling the Company field on the Case record, you should be able to tweak this to do what you need:

    //disable the actual field the user sees (alternatively you could hide it)

    document.getElementById("case_primarycompanyidTEXT").disabled = true;

    //hide the magnifying glass button/icon

    document.getElementById("SearchSmallAdvcase_primarycompanyid").style.visibility = "hidden";

    //hide the little green arrow/dropdown

    document.getElementById("SearchSmallcase_primarycompanyidIMG").style.visibility = "hidden";

    HTH

    Mark.

  • 0

    Hi Mark,

    Thank you, this solved the problem!

    An extension to the above, can this same code be used to check the field value when the form is loaded?

    Would like the same check to occurs when the page is loaded for the first time.

    EAD

  • 0

    Hi

    If you are doing something with client-side JavaScript in the Custom Content area then you could use document.getElementById("oppo_parentcompany").value, but this will only work when the screen is in Edit mode as otherwise the field object will not exist.

    In the CreateScript you can use CRM.GetContextInfo("Opportunity", "oppo_parentcompany") to get the value and this will work in all modes, however if you set ReadOnly=true there then you will not then be able to toggle the field between disabled/enabled using the previous script, as once you have set the field to read-only in the CreateScript there will be no field object to enable/disable.

    If you need a combination of those, you will have to either have to use CRM.AddContent in the CreateScript to render some JavaScript which sets a variable on the client side (which you can then access in a Custom Content function), or do it all client-side using Jeff's method for grabbing server-side values on the client-side, hecommunity.sagecrm.com/.../sage-crm-v7-1-grabbing-serverside-information-using-a-sdata-webservice-call-ajax.aspx

    HTH

    Mark.

  • 0

    Thank you,

    Using you script with minor tweaks this is now working for both On create and Entry.

    Really appreciate the help.

    EAD