How to make Case description readonly after save?

How to make  Cases description readonly in editview after it has been save?

TIA,

Longki Dela Cruz

Parents
  • Roland Cadavos,

    I presume that you only want it to become read-only once it has been populated with something. There are a few ways that you can do this, with each option depending slightly on the version/edition of Sugar you are using and the exact rules that need to be enforced.

    However a base level resolution for this is to create a duplicate description field and make one a calculated field to copy the value of the other. You would then set dependencies so that the initial fields hides when the calculated one is populated with something, and use the same principal on the calculated field. This will make it look as if the field is suddenly becoming read-only, where in fact it is simply swapping the fields over.

    If you are looking for something more than this let me know.

  • Hi Longki,

    You have to make few changes in your dependency code to make it work when it is saved.You have given triggerFields as description,so dependency will get triggered,when we filled value for that.

    But,If you want to make it readonly once it is saved,you have to remove description field from triggerFields.Then it will work properly.

    Here is the modified dependency code.check it out.

    <?php
    $dependencies['Cases']['description_readonly'] =    array(
        'hooks' => array("edit"),
        'trigger' => 'true', //check if  the field has a value so that it will trigger
        'triggerFields' => array( ),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
            array(
                'name' => 'ReadOnly',
                //The parameters passed in will depend on the action type set in cases.description field
                'params' => array(
                    'target' => 'description',
                    'value'=> 'not(equal($description,""))',
                ),
            ),
        ),
    );
    
Reply
  • Hi Longki,

    You have to make few changes in your dependency code to make it work when it is saved.You have given triggerFields as description,so dependency will get triggered,when we filled value for that.

    But,If you want to make it readonly once it is saved,you have to remove description field from triggerFields.Then it will work properly.

    Here is the modified dependency code.check it out.

    <?php
    $dependencies['Cases']['description_readonly'] =    array(
        'hooks' => array("edit"),
        'trigger' => 'true', //check if  the field has a value so that it will trigger
        'triggerFields' => array( ),
        'onload' => true,
        //Actions is a list of actions to fire when the trigger is true
        'actions' => array(
            array(
                'name' => 'ReadOnly',
                //The parameters passed in will depend on the action type set in cases.description field
                'params' => array(
                    'target' => 'description',
                    'value'=> 'not(equal($description,""))',
                ),
            ),
        ),
    );
    
Children