function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DescendantDescendant 

trigger based on status, doesn't work

Hi everyone,

I implemented a trigger 4 months ago, which worked perfectly during this period. Now I am facing the issue, that the trigger is not working properly.

The trigger is base on a Status of the object License as you can see in the code:

trigger XXX on License (before update) {

			for(Integer i=0;i<trigger.new.size();i++){
				if(trigger.new[i].Status__c == 'Request Received'){
						//call future function, 
							//create a serial number, 
							//create an asset for it, attached to the License object. 
							//Then change status to "License Created" and update the object;
				}
				if(trigger.new[i].Status__c == 'License Created'){
                	// send the license to a user                             
					trigger.new[i].Status__c = 'License Sent';
				}
			}	
}

When a new request is received, the trigger is fired, the future function is called and the status should have been changed, because after that, the trigger is fired again and it tries to send the mail. When this happens, I receive the following exception:

first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, XXX: execution of BeforeUpdate
caused by: System.EmailException: SendEmail failed. First exception on row 0; first err

When I take a look at the object, the License Status is still "Received" and no asset was created. Moreover, the object history says, that the status hasn't been changed at all. Strange right? After that, I commented the entire if statement for the mail sending and then after receiving a new request, the future function was called, the status was successfully changed to "License created" and the asset was also created.

The problem is, that I cannot realize, why this is happening. I believe, that the reason is the new rellease 14.

Could somebody tell me, how to fix this issue?

Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
Check this thread>it will be helpful i guess
https://developer.salesforce.com/forums/ForumsMain?id=906F00000009EdtIAE