Announcement

Collapse
No announcement yet.

Trigger value in the sub-status when status values changes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trigger value in the sub-status when status values changes

    Hi team,

    In case management i have status field i.e. Enum type so whenever I change the value in the field it trigger to sub-status field to null so how we can do this

  • #2
    In Administration > Entity Manager > Case > Formula > Before Save Custom Script put:
    Code:
    if (entity\isAttributeChanged('status')) {
        cSubstatus = null
    }​
    Replace cSubstatus with the name of your field.

    Similar functionality can also be implemented using Workflow or BPMN if you have the Advanced Pack extension.

    Comment


  • #3
    Hi msonu719,

    You will have to use a custom Dynamic Handler: https://docs.espocrm.com/development/dynamic-handler.

    Please note that this option is working, but may not be entirely correct from a coding point of view, so perhaps one of the more experienced users will correct it. This option will also only work for Full Edit mode (pressing the Edit button in the upper left corner).

    Also, note that if the cSubstatus field has an Enum type, there should also be an empty option in the settings for this field.

    Steps:
    1. Create an {ESPO_DIR}/client/custom/src/case-dynamic-handler.js file with the following content:
      Code:
      define('custom:case-dynamic-handler', ['dynamic-handler'], (Dep) => {
      	
      	   return class extends Dep {
      	
      	       init() {
      	           this.recordView.listenTo(this.model, 'change:status', (model, value, options) => {
      	               if (!options.ui) {
      	                   return;
      	               }
      	
      	               if (value) {
      	                   setTimeout(() => this.model.set('cSubstatus', ''), 1);
      	                   }
      	           });
      	       }
      	   };
      	});​
    2. Add the following string to the {ESPO_DIR}/custom/Espo/Custom/Resources/metadata/clientDefs/Case.json file:
      Code:
      "dynamicHandler": "custom:case-dynamic-handler"​
      The entire file content might look like this:
      Code:
      	{
      	"kanbanViewMode": true,
      	"color": null,
      	"iconClass": "fas fa-briefcase",
      	"dynamicHandler": "custom:case-dynamic-handler"
      	}
      	​
    3. Clear cache in the Administration > Clear Cache.
    Please let me know if this option works for you.
    Last edited by lazovic; 10-14-2024, 01:19 PM.

    Comment

    Working...
    X