• Amrik Das
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies

Need help to generate test class for the following trigger.

 

trigger RestrictCreate on Opportunity (before insert, before update) 
{
    //List<Account> lstAcc = [select name from account where type='Distributor' and SSS_SAP_ID_Actual__c LIKE '008%'];
    for(Opportunity opp : Trigger.new)
    {
        System.debug('Account = ' + opp.Account);
        System.debug('oppty = ' + opp);
        System.debug('Oppty.Account.Type = ' + opp.Account.type);
        System.debug('SAP ID ACtual = ' + opp.Account.SSS_SAP_ID_Actual__c);
        Account test = [select id,name,type,SSS_SAP_ID_Actual__c from account where id=:opp.accountId];
        System.debug(test);
        Id profileId=userinfo.getProfileId();
        if(profileId != '00e30000000i9fA')
        {
            if((test.type=='Distributor') && (test.SSS_SAP_ID_Actual__c.startsWith('008')))
            opp.addError('Can not link Opportunity with Account of Type Distributor & SAP ID Actual starting with 008');
            return;
        }
    }
}

I wish to show the status and comments of an approval process in a VF Page.

How should I proceed with it?