• Abhijeet Kumar 7
  • NEWBIE
  • 0 Points
  • Member since 2019
  • Salesforce Developer
  • In

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi Trailbazer ,, Requestiong you to help me out for the sitution i got stuck:
Below is my Logic which is running on the before update :
Trigger Logic :
public static void wmgRemoveOldGroupQueue(Map<Id,Case> newMap, Map<Id,Case> oldMap){
        String wmgRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('WMG_Operations_Workflow').getRecordTypeId();
        for (Case o : newMap.values()) {
            if (o.RecordTypeId == wmgRecordTypeId && !((String)o.OwnerId).startsWith('005') &&
                (o.OwnerId != oldMap.get(o.Id).OwnerId)) {
                o.ANN_Accepted_From_Queue__c = '';
            }
        }
    }

And Below is the Test Class to cover this :
static testMethod void wmgRemoveOldQueueTest() {        
    //setup 

    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; 
    String wmgRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('WMG_Operations_Workflow').getRecordTypeId();
    String assertMsg = 'Accepted From Queue could not clear out';        
    QueueSobject q = [SELECT QueueId, Queue.Name FROM QueueSobject WHERE SObjectType = 'Case' and Queue.Name = 'WMG Ops - Licensing' LIMIT 1];

    Case c = new Case();
    c.OwnerId = thisUser.Id;
    c.RecordTypeId = wmgRecordTypeId;
    c.ANN_Accepted_From_Queue__c = q.Queue.Name;

    insert c;
    System.debug('&&&&&&&&&&&&&&&&&&&&&&&&OwnerIdatinsert'+c.OwnerId);
   /* c = [SELECT OwnerId, ANN_Accepted_From_Queue__c, RecordTypeId FROM Case WHERE Id = :c.Id];
    c.OwnerId = thisUser.Id;
    update c;*/


Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User tuser = new User(  firstname = 'fName',
                        lastName = 'lName',
                        email='test123@securian.com',
                        Username = 'unique@test36.com',
                        EmailEncodingKey = 'ISO-8859-1',
                        alias='test123',
                        TimeZoneSidKey = 'America/Los_Angeles',
                        LocaleSidKey = 'en_US',
                        LanguageLocaleKey = 'en_US',
                        ProfileId = p.Id);
   Test.startTest();

        insert tuser ;

            c.ownerId = tuser.id;
            update c;
            c.ownerId = q.QueueId;
            update c;


 Test.stopTest();
    System.debug('&&&&&&&&&&&&&&&&&&&owneridatupdate'+c.OwnerId);
    System.debug('c.ANN_Accepted_From_Queue__c = '+C.ANN_Accepted_From_Queue__c);

    System.assertEquals('' ,[SELECT ANN_Accepted_From_Queue__c FROM Case WHERE Id = :c.Id].ANN_Accepted_From_Queue__c, assertMsg);    


}
Even though i am changing the owner of the Case which i am inserting in the Test Class, but still my last assert statement is failing in the test class: :
The Assert Statement Which is failing is below :
System.assertEquals('' ,[SELECT ANN_Accepted_From_Queue__c FROM Case WHERE Id = :c.Id].ANN_Accepted_From_Queue__c, assertMsg);
not able to cover this below condition in the actual logic:
(o.OwnerId != oldMap.get(o.Id).OwnerId))



 
Hi Trailbazer ,, Requestiong you to help me out for the sitution i got stuck:
Below is my Logic which is running on the before update :
Trigger Logic :
public static void wmgRemoveOldGroupQueue(Map<Id,Case> newMap, Map<Id,Case> oldMap){
        String wmgRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('WMG_Operations_Workflow').getRecordTypeId();
        for (Case o : newMap.values()) {
            if (o.RecordTypeId == wmgRecordTypeId && !((String)o.OwnerId).startsWith('005') &&
                (o.OwnerId != oldMap.get(o.Id).OwnerId)) {
                o.ANN_Accepted_From_Queue__c = '';
            }
        }
    }

And Below is the Test Class to cover this :
static testMethod void wmgRemoveOldQueueTest() {        
    //setup 

    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; 
    String wmgRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('WMG_Operations_Workflow').getRecordTypeId();
    String assertMsg = 'Accepted From Queue could not clear out';        
    QueueSobject q = [SELECT QueueId, Queue.Name FROM QueueSobject WHERE SObjectType = 'Case' and Queue.Name = 'WMG Ops - Licensing' LIMIT 1];

    Case c = new Case();
    c.OwnerId = thisUser.Id;
    c.RecordTypeId = wmgRecordTypeId;
    c.ANN_Accepted_From_Queue__c = q.Queue.Name;

    insert c;
    System.debug('&&&&&&&&&&&&&&&&&&&&&&&&OwnerIdatinsert'+c.OwnerId);
   /* c = [SELECT OwnerId, ANN_Accepted_From_Queue__c, RecordTypeId FROM Case WHERE Id = :c.Id];
    c.OwnerId = thisUser.Id;
    update c;*/


Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User tuser = new User(  firstname = 'fName',
                        lastName = 'lName',
                        email='test123@securian.com',
                        Username = 'unique@test36.com',
                        EmailEncodingKey = 'ISO-8859-1',
                        alias='test123',
                        TimeZoneSidKey = 'America/Los_Angeles',
                        LocaleSidKey = 'en_US',
                        LanguageLocaleKey = 'en_US',
                        ProfileId = p.Id);
   Test.startTest();

        insert tuser ;

            c.ownerId = tuser.id;
            update c;
            c.ownerId = q.QueueId;
            update c;


 Test.stopTest();
    System.debug('&&&&&&&&&&&&&&&&&&&owneridatupdate'+c.OwnerId);
    System.debug('c.ANN_Accepted_From_Queue__c = '+C.ANN_Accepted_From_Queue__c);

    System.assertEquals('' ,[SELECT ANN_Accepted_From_Queue__c FROM Case WHERE Id = :c.Id].ANN_Accepted_From_Queue__c, assertMsg);    


}
Even though i am changing the owner of the Case which i am inserting in the Test Class, but still my last assert statement is failing in the test class: :
The Assert Statement Which is failing is below :
System.assertEquals('' ,[SELECT ANN_Accepted_From_Queue__c FROM Case WHERE Id = :c.Id].ANN_Accepted_From_Queue__c, assertMsg);
not able to cover this below condition in the actual logic:
(o.OwnerId != oldMap.get(o.Id).OwnerId))



 
Hello,

I have give permission to particular group to convert lead assigned to them. By default they has all access on account and contact. I want they should edit account on lead conversion but other times they can not edit account. How is this possible through validation rule.

Thanks!