Регистрация  |  Вход

Рассылка емейлов тригером.

Всем привет!

Скажите пожалуйста, у кого-нибудь возникала такая ошибка при рассылки емейлов тригером?

Validation Errors While Saving Record(s)

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger cwharf_MbO_app.MbO_ApprovalNotification caused an unexpected exception, contact your administrator: cwharf_MbO_app.MbO_ApprovalNotification: execution of BeforeUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, Object type not accessible. Please check permissions and make sure the object is not in development mode: FirstName, LastName, MiddleName, InformalName, Suffix, Id FROM User ^ ERROR at Row:1:Column:41 No such column 'InformalName' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.. Original queryString was: 'SELECT FirstName, LastName, MiddleName, InformalName, Suffix, Id FROM User WHERE id = '000000000000000'': []: (cwharf_MbO_app)".

В dev системе все работает отлично, но когда пакет установили на другую инстанцию, то появилась эта ошибка.
Поле 'InformalName' которое о котором говорится в ошибке нигде его нету. С начало на "MiddleName" выдавал ошибку, но я нашел где установить "MiddleName", но а о 'InformalName' вообще ничего нигде не сказано.

Вот метод рассылки емейлов:

public void RecipientRecordCreator(List<String> recipient, String oMBOF_Id, List<EmailTemplate> listTemplate, String nameTemplate)
{
System.debug('Recipients: '+recipient);
System.debug('Form: '+oMBOF_Id);
System.debug('Email templates: '+listTemplate);
System.debug('Template name: '+nameTemplate);

List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
Id templateId;
if(!listTemplate.isEmpty())
{
for(EmailTemplate lt: listTemplate)
{
if(lt.developerName==nameTemplate)
{
templateId = lt.id;
}
}
if(templateId!=null)
{
if(!recipient.isEmpty())
{
for(String recip: recipient)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setTemplateId(templateId);
email.setTargetObjectId(recip);// recipian
email.setWhatId(oMBOF_Id);// id form
email.setSaveAsActivity(false);
emails.Add(email);
}
}
}

Messaging.sendEmail(emails);
}


}

А вот вызов метода:

RecipientRecordCreator(new String[] {oMBOF.ManagerId__c}, oMBOF.Id, templateIds, 'MbO_et_Goals_Approved_v');

Всем привет!

Скажите пожалуйста, у кого-нибудь возникала такая ошибка при рассылки емейлов тригером?

Validation Errors While Saving Record(s)

There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger cwharf_MbO_app.MbO_ApprovalNotification caused an unexpected exception, contact your administrator: cwharf_MbO_app.MbO_ApprovalNotification: execution of BeforeUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, Object type not accessible. Please check permissions and make sure the object is not in development mode: FirstName, LastName, MiddleName, InformalName, Suffix, Id FROM User ^ ERROR at Row:1:Column:41 No such column 'InformalName' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.. Original queryString was: 'SELECT FirstName, LastName, MiddleName, InformalName, Suffix, Id FROM User WHERE id = '000000000000000'': []: (cwharf_MbO_app)". 

В dev системе все работает отлично, но когда пакет установили на другую инстанцию, то появилась эта ошибка.
Поле 'InformalName' которое о котором говорится в ошибке нигде его нету. С начало на "MiddleName" выдавал ошибку, но я нашел где установить "MiddleName", но а о 'InformalName' вообще ничего нигде не сказано.

Вот метод рассылки емейлов:

    [code]public void RecipientRecordCreator(List<String> recipient, String oMBOF_Id, List<EmailTemplate> listTemplate, String nameTemplate)
    {
        System.debug('Recipients: '+recipient);
        System.debug('Form: '+oMBOF_Id);
        System.debug('Email templates: '+listTemplate);
        System.debug('Template name: '+nameTemplate);
        
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();       
        Id templateId;
        if(!listTemplate.isEmpty())
        {
            for(EmailTemplate lt: listTemplate)
            {
                if(lt.developerName==nameTemplate)
                {
                    templateId = lt.id;
                }
            }
            if(templateId!=null)
            {
              if(!recipient.isEmpty())
              {
                for(String recip: recipient)
                {
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setTemplateId(templateId);
                    email.setTargetObjectId(recip);// recipian
                    email.setWhatId(oMBOF_Id);// id form
                    email.setSaveAsActivity(false);
                    emails.Add(email);
                }       
              }
            }
        
            Messaging.sendEmail(emails);
        }


    }[/code]

А вот вызов метода:

[code]     RecipientRecordCreator(new String[] {oMBOF.ManagerId__c}, oMBOF.Id, templateIds, 'MbO_et_Goals_Approved_v');[/code]

Судя по ошибке или нет поля InformalName в пакете, или нет доступа к этому полю.

Судя по ошибке или нет поля InformalName в пакете, или нет доступа к этому полю.