Allowing Users to Add New Records in Read-Only Forms

This topic describes how to allow the user to add a new record in a read-only form. The example in this topic configures a form that allows the user to create new accounts but not to change existing accounts. If you use this configuration, then the user cannot use the scrollbar and cannot drill down on a record.

To allow users to add new records in read-only forms

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

  2. Add the following code to the account_form function:

    ctx.form.enabled = (ctx.item_ex.get_id() == null);
    

    This code allows the user to create a new account and to edit account information until the user saves the account. If the user saves the account, then the user cannot edit the account.

    When Siebel CRM Desktop saves an item it sets an Id for that item. This code determines if Siebel CRM Desktop has set an Id for the current item. It returns one of the following values:

    • True. An Id is not set for the item. This value indicates that the user can edit the form.

    • False. An Id is set for the item. This value indicates that the user cannot edit the form.

  3. Add the following code to make the view readable:

    ctx.form.view_name.enabled = true;
    

    For example:

    ctx.form.accounts_view.enabled = true;
    

    accounts_view is a view control that displays accounts from the forms_xx.xml file. If you make a form read-only in step 2, then it is recommended that you make the view that the form uses readable so that the user can scroll down through the form, can scroll to the side of the form, and can drill down on a record.

  4. (Optional) To allow the user to edit information for a new account that the user has saved but not synchronized, you can change the code that you added in step 2 to the following:

    form_helpers.enable_form(ctx.form, !ctx.security_descriptor.is_synced());
    

    This code determines if Siebel CRM Desktop has synchronized the current object and then does the following:

    • If the current object is not synchronized, then it allows the user to edit the object.

    • If the current object is synchronized, then it does not allow the user to edit the object.

  5. Test your modifications, and then republish the customization package.

    For more information, see Republishing Customization Packages.