+ Start a Discussion
顺娟 许顺娟 许 

How to change the code in order that some users in specific profiles do not restricted by the code?

Here's the code:
        if (UtilQuote.isUpdate) {
            for (Quote qu : Quotes)
                if (trigger.newMap.get(qu.Id).Cnt_of_Quote_line__c >= trigger.oldMap.get(qu.Id).Cnt_of_Quote_line__c )
                    List<QuoteLineItem> inActiveProLst = [Select Id,PricebookEntry.Product2.Id,PricebookEntry.Product2.Name From QuoteLineItem where QuoteId IN:quotes and PricebookEntry.Product2.IsActive = false]; 
                    for (QuoteLineItem qli : inActiveProLst ) {
                        trigger.new[0].addError('该报价单有无效的产品:' + qli.PricebookEntry.Product2.Name + ',请重新选择产品!');

how can I exclude user in these two profiles?
$User.ProfileId <>"00e90000000qoiZ"
$User.ProfileId <>"00e90000000pV2l"

it's quite easy in validation rules but I don't know how to change the code, would somebody help?

Thank you very much in Advance!!!
Set<Id> excludeProfileList = new Set<Id>();
for(Profile thisProfile : [SELECT Id, Name FROM Profile WHERE Name =: 'xxxx']){

    // Don't perform any operation
    // put your logic in here