Making Fields Read-Only

To make a field read-only, you disable the corresponding control on the form that references the field that you must make read-only. The example in this topic makes the Opportunity Name field on the opportunity form read-only.

To make a field read-only

  1. Use a JavaScript editor to open the forms.js file.

    For more information, see JavaScript Files in the Customization Package.

  2. Locate the function that is associated with the form you must modify.

    For example, to make an item on the Opportunity form read-only, locate the following function:

    // OPPORTUNITY FORM SCRIPTS // 
    function opportunity_form(ctx) 
    { 
    }
    

    For more information, see Customizing Form Functions.

  3. In the function you located in step 2, locate the following statement:

    set_controls_access() 
    
  4. Add the following code after the statement you located in step 3:

    ctx.form[control_id].enabled = value;
    

    where:

    • control_id is the name of the control in the forms_xx.xml file.

    • value determines if the field is read-only. You can use one of the following values:

      • True. Make the field editable.

      • False. Make the field read-only.

      For this example, you add the following code:

      ctx.form["opportunity"].enabled = false;
      
  5. The ctx.form file includes form controls that Siebel CRM Desktop maps to corresponding fields. For information about the forms_xx.xml file, see Files That the Customization Package Contains.

  6. Open the client and then navigate to the Opportunity form.

  7. Open an opportunity and make sure you cannot modify the Opportunity Name.

  8. Republish the customization package.

    For more information, see Republishing Customization Packages.