Make a field Read Only after first entry

We have a situation where once a field has been populated by the user, we want that field to be locked for further editing (i.e Read Only).

I have seen other questions and answers in the forum suggesting:

1. Use a workflow - I can't see anywhere in workflow how you can change the field level settings to Read Only.

2. Use Dependencies - for non drop down I can only see a Visible If option in Studio

3. Use Drop Down Dependencies - The field is a date field - I'm not sure Dependent Drop Downs would work anyway.

4. Role Based Views - Can't see that being a solution.

5. Use custom code - site is sugar on demand so not an option.

Any ideas at all - I don't think it is possible ?

Thanks in advance for any ideas.

  • I had (have) a similar situation involving a date and I solved it by adding a field that was set "read only" for the Sales Reps, and populated with a workflow using the "First Update" option for the workflow Start.

    The workflow is set to run with the first change to the date field that the rep populates.  The workflow copies the date to the "read only" field which I named "Original ___ Date".  If the rep changes the date, we know when it was done because the field is set to "Audit" - Management could inquire why the sales rep changed the date if they do it :-)

    I haven't done this step, but you could probably set the original date field to be visible only if it's empty, or based on some other setting in the record. 

    Bud Hartley | Cape Foulwind, NZ (and Oregon, USA)

  • You can do this with Dependencies, but not through Studio. At this time it requires custom code to add the Dependency. which can be added to an OnDemand instance using a Module Loadable Package.

    Module Loadable Package:

    http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_8.0/Cookbook/Module_Loadable_Packages/ :

    Dependencies

    http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Sugar_Logic/Dependency_… 

    Add a file in custom/Extension/modules/module_name/Ext/Dependencies/

    with code similar to the following:

    <?php
       $dependencies['Accounts']['readonly_fields'] = array(
            'hooks' => array("edit"),
            'trigger' => 'true',
            'triggerFields' => array('lock_field_c'),
            'onload' => true,
            'actions' => array(
                array(
                    'name' => 'ReadOnly',
                    'params' => array(
                        'target' => 'lock_field_c',
                        'value' => 'not(equal($lock_record_c,""))',
                    ),
                ),
            ),
        );

    The only issue I see with this is that once a value is placed in the field, no one,not even an Admin can change it.

    You may want to create checkbox that when checked would make your field Read-Only using a Dependency and then make that field only accessible by Admins via Roles.