Skip to main content
edited body
Source Link
Nagendra Singh
  • 9.1k
  • 6
  • 29
  • 60

Just to give a sample and one of the ways to implement this:

I created an approval process, just added an action to update any field. In your case it will be your specific field.

DummyApprovalprocess

After that just wrote a trigger on Opportunity beforeUpdate like this. You can add your conditions.

trigger OpportunityTrigger on Opportunity (before update) {

    if(trigger.isUpdate && trigger.isBefore) {        
        for(Opportunity s : Trigger.new){                        
            s.addError('You must add at least one osr Product to your Request');
        }
    }

}

And when submitting for approval:

enter image description here

got this message:

enter image description here

NotNow you will have to fix your code for compilation errors and all, but this was just to show that this flow does work and allows us to put a validation in approval process.

Just to give a sample and one of the ways to implement this:

I created an approval process, just added an action to update any field. In your case it will be your specific field.

DummyApprovalprocess

After that just wrote a trigger on Opportunity beforeUpdate like this. You can add your conditions.

trigger OpportunityTrigger on Opportunity (before update) {

    if(trigger.isUpdate && trigger.isBefore) {        
        for(Opportunity s : Trigger.new){                        
            s.addError('You must add at least one osr Product to your Request');
        }
    }

}

And when submitting for approval:

enter image description here

got this message:

enter image description here

Not you will have to fix your code for compilation errors and all, but this was just to show that this flow does work and allows us to put a validation in approval process.

Just to give a sample and one of the ways to implement this:

I created an approval process, just added an action to update any field. In your case it will be your specific field.

DummyApprovalprocess

After that just wrote a trigger on Opportunity beforeUpdate like this. You can add your conditions.

trigger OpportunityTrigger on Opportunity (before update) {

    if(trigger.isUpdate && trigger.isBefore) {        
        for(Opportunity s : Trigger.new){                        
            s.addError('You must add at least one osr Product to your Request');
        }
    }

}

And when submitting for approval:

enter image description here

got this message:

enter image description here

Now you will have to fix your code for compilation errors and all, but this was just to show that this flow does work and allows us to put a validation in approval process.

Source Link
Nagendra Singh
  • 9.1k
  • 6
  • 29
  • 60

Just to give a sample and one of the ways to implement this:

I created an approval process, just added an action to update any field. In your case it will be your specific field.

DummyApprovalprocess

After that just wrote a trigger on Opportunity beforeUpdate like this. You can add your conditions.

trigger OpportunityTrigger on Opportunity (before update) {

    if(trigger.isUpdate && trigger.isBefore) {        
        for(Opportunity s : Trigger.new){                        
            s.addError('You must add at least one osr Product to your Request');
        }
    }

}

And when submitting for approval:

enter image description here

got this message:

enter image description here

Not you will have to fix your code for compilation errors and all, but this was just to show that this flow does work and allows us to put a validation in approval process.