• Sarthak Bajaj 14
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 9
    Replies
Hi All,

I have a trigger which does not allow changing of parent record status to implemented till the time child record status is implemented.
Below is the trigger for the same:
trigger RequirementStatusUpdate on Requirement__c (before update) {
	
    Set<Id> setRequirement = new Set<Id>();

    for(Requirement__c rm : trigger.new)
        if(rm.Status__c == 'Implemented')
            setRequirement.add(rm.Id);

    Map<Id, List<System_Action__c>> mapCaseToBuildCard
        = new Map<Id, List<System_Action__c>>();

    for(
        System_Action__c iCard :
        [
            SELECT
                Id, Requirement__c
            FROM
                System_Action__c
            WHERE 
                Requirement__c IN :setRequirement AND
                Status__c != 'Done/Tested'
        ]
    ){
        if(
            !mapCaseToBuildCard.containsKey(
                iCard.Requirement__c
            )
        ){
            mapCaseToBuildCard.put(
                iCard.Requirement__c,
                new List<System_Action__c>{
                    iCard
                }
            );
        }
        else{
            mapCaseToBuildCard.get(
                iCard.Requirement__c
            ).add(iCard);
        }
    }

    for(Requirement__c rm : trigger.new){
        if(rm.Status__c == 'Implemented'){
            if(
                mapCaseToBuildCard.containsKey(rm.Id) &&
                mapCaseToBuildCard.get(
                    rm.Id
                ).size() > 0
            ){
                rm.addError(
                    'You cannot Change the Status to implemented this Requirement. ' + 
                    'There are Open Build Card' + 
                    ' under this Requirement.'
                );
            }
        }
    }
}
Requirement: Parent Object
System Action: Child Object

In test class, so far I have created a dummy Requirement object data and the System Action object data.
but unable to proceed forward with the coverage.
Could you please suggest how exactly I need to cover the code coverage for data presnt in set and checking the if logic criteria.

So far I have written:
@isTest
public class RequirementStatusUpdateTest {
	static testMethod void RequirementStatusUpdateTest(){
    	Recordtype rname = [Select id, name from recordtype where name = 'SFDC Requirement'];
        List<Requirement__c> Req= new List<Requirement__c>();
        //Set up user
        User u1 = [SELECT Id,Name FROM User WHERE GE_ES_SSO__c='502690635'];
      //  Initiative_Project__c VerticalTeam = [select id from Initiative_Project__c where id = 'a0GC000000Liwkw' limit 1];
        
        //Run As U1
        System.runAs(u1){
            test.startTest();
            
            try{
//parent record
            Requirement__c rObj = new Requirement__c(
                RecordTypeid = rname.id,
                Requirement_Type1__c = 'Production Change Request',
                SFDC_Project__c = 'a0GC000000Liwkw',
                Development_Ownership__c= 'P&W > HQ',
                User_Story_Name__c = 'Test class coverage class',
                Tier_2_P_L__c = 'HQ',
                Target_Release__c= 'TBD',
                Prioritization_P_L__c= 'P&W Power Services',
                SFDC_P_L_Owner__c=u1.Id,
                User_Story__c='Test',
                Release__c='TBD1',
                Status__c = 'Draft');
            insert rObj;
            
            

//child record
            System_Action__c BCObj = new System_Action__c();
            BCObj.Requirement__c = rObj.id;
            BCObj.System_Action_Name__c = 'Test coverage';
            BCObj.Status__c = 'Draft';
            insert BCObj;
             
                
                
              
				Set<Requirement__c> setRequirement = new Set<Requirement__c>();
				setRequirement.add(rObj);
                
                
                rObj.Status__c = 'Implemented';
                Update rObj;
            
        
    }
            catch(Exception e){
         
              
}
}
}

Thanks in advance.

Sarthak
We had a release 3 month back.And few picklist values were changed(few were removed and few were added).
Also few picklist field are having history tracking on, and few are not having the field history on. (Fields are under Opportunity Object)

Is there a way to find all the old picklist values that were part of the picklist field before the release ?
I tried to find using OpportunityFieldHistory but the data was not accurate somehow
Thanks in Advance.
Hi All,

I have a requirement where there is a need to insert records in salesforce instead of updating the excel and attaching the excel each time in salesforce.
Currently Each time data in excel needs an update, we need to download the excel, update the excel and then we have to upload it to salesforce again.
Is there a way to directly store the sheet/record in salesforce so that we can directky modify the records in salesforce.
Note: The excel sheet contains username and password as well, therefore storing it in simple object will not be an ideal way.

Thanks in advance

Regards,
Sarthak
Hi All,

One of our User is unable to view the 'User Detail' button in llighning User detail page. But same user is able to view User Details of other users in Classic version.
I have checked the profile level access and layout access, everything seems to be set correctly, but in lilghtning User is not able to see the User Detail button on right hand sideUser-added image

Thanks in advance
Hi,

I have a requirement where I need to add validation rule(saying that a field is blank), but that validation should fire if in approval process the stage gets to in review/ or the approver is the Queue of the assigned approver.

I tried using validation rule, but it seems it is not achievable via validation rule.
It seems I need to write a trigger and use StepsAndWorkitems to get the actorId.

Can someone please guide me on how to achive this requirement?
 
Hi,
   I am confused on this.I want to allow a user in a role to have a feature to change the owner of Account and Opportunity for iother users in the same role.
Scenerio:
In a role ROLE1, say 4 users are there-A,B,C,D
Now A wants to have the access so that he may change the Account and Opportunities owned by B,C,D can be changes by him.

Can anyone suggest me how can i Achieve this.
Can this be done throgh sharing rule.IF yes-how?
Or do i need to Shift user A a level up in hierarchy.
Apex class
public with sharing class SF1AddProductCC {
    
    public String recordType { get; set;} 
    public boolean priceBookSelected { get; set; }
    public boolean GVWSOpp { get; set; }
    public boolean nonGVWSOpp { get; set; }

    public Opportunity opp {get; set;}
    public list<PriceBookWrapper> lstPriceBooks { get; set; }
    public list<OppLineItemWrapper> lstOppItems { get; set; }
    
    public boolean productSearched { get; set; }
    public List<SelectOption> lstPriceBookOptions{ get; set; }
    public String priceBookId { get; set; }
    
    
    public string keyword { get; set; }
    public List<SelectOption> lstFilterFields{ get; set; }
    public string field { get; set; }
    private ApexPages.StandardController standardController; 
    
    
    
    public SF1AddProductCC(ApexPages.StandardController standardController){
        
        
        this.standardController = standardController;
        opp = (Opportunity) standardController.getRecord();
        
        recordType = ApexPages.currentPage().getParameters().get('recordType');
        
        priceBookSelected = false;
        productSearched = false;
               
String recordtypename = [select recordtype.name from opportunity where id =: opp.id limit 1].recordtype.name;
        system.debug('recordtypename#####'+ recordtypename);

if(recordtypename == 'GVWS Zone Opportunity' || recordtypename == 'GVWS National Accounts Opportunity')
{
GVWSOpp = true;
nonGVWSOpp = false;
   }
else
{
GVWSOpp = false;
nonGVWSOpp = true;
}

        if(GVWSOpp == false && nonGVWSOpp == true)
        {    
         //TODO: Check if the PriceBook is already selected
        system.debug('****before getPriceBookOptions method*****');
        getPriceBookOptions();
        system.debug('****after getPriceBookOptions method*****');
        }
        setProductSearchLists();
          

        
        /*
            If there is only one Pricebook2 entry, we set the selected
            Pricebook2 and then call save.
        */
        
         if(GVWSOpp == false && nonGVWSOpp == true)
            {
        if(lstPriceBookOptions.size() == 1){
          
            priceBookId = lstPriceBookOptions[0].getValue();
            system.debug('********priceBookId for Other*********'+priceBookId );
            }
            }      
            else if (GVWSOpp == true && nonGVWSOpp == false)
            {
             if(recordtypename == 'GVWS Zone Opportunity')
             {
             priceBookId = [SELECT Id FROM Pricebook2 WHERE Name = 'GVWS Zone Price Book'].Id;
             system.debug('********priceBookId for Zone*********'+priceBookId );
             }
             else if (recordtypename == 'GVWS National Accounts Opportunity')
             {
             pricebookid =  [SELECT Id FROM Pricebook2 WHERE Name = 'GVWS NA Price Book'].Id  ;                                 
             system.debug('********priceBookId for NA*********'+priceBookId );
             }    
                  system.debug('Pricebook Id is'+pricebookId);
      
            }
            save();
        }
        
       //  end of constructor
    
    
    public void save(){
        list<PriceBookEntry> lstPBEntries = new list<PriceBookEntry>();
        priceBookSelected=true;
        
        lstPBEntries = [Select Id, Name, pricebook2.Name, product2.Name, product2.Description, product2.family 
                                            from PricebookEntry where pricebook2Id = :priceBookId  AND product2.IsActive = true and pricebook2.IsActive = true and IsActive = true];
        createPriceBookWrapperObjects(lstPBEntries);
         
    }   //  end of save
    
    public pageReference saveOpptyLineItem(){
        
        list<OpportunityLineItem>lstOpptyLineItems = new list<OpportunityLineItem>();
        for(OppLineItemWrapper objOppLineItemWrap :lstOppItems ){
            
            objOppLineItemWrap.opptyLineItem.TotalPrice = objOppLineItemWrap.premium;
            lstOpptyLineItems.add(objOppLineItemWrap.opptyLineItem);
        }
        
        if(lstOpptyLineItems.size() > 0){
            
            insert lstOpptyLineItems;
           
        }
        
        
// Rahul Mehta Commented below two lines for INC00019824 - SF1 issue
       // pageReference page = new pageReference('/'+ opp.Id);
       // return page;
        return Null;
    }
    
    public void cancel(){
        
    }   //  end of cancel
    
    public void searchProducts(){
        list<PriceBookEntry> lstPBEntries = new list<PriceBookEntry>();
        system.debug('Pricebook Id is'+pricebookId);
        string likeStr = '%'+ keyword +'%';
        lstPBEntries = [SELECT Id, Name, pricebook2.Name, product2.Name, product2.Description, product2.family 
                                            FROM PricebookEntry 
                                            WHERE pricebook2Id = :priceBookId 
                                              AND product2.Name like :likeStr
                                              AND product2.IsActive = true ];
        createPriceBookWrapperObjects(lstPBEntries);
        
    }   //  end of searchProducts
    
    public void selectProducts(){
        lstOppItems = new list<OppLineItemWrapper>();
         system.debug('*****lstPriceBooks********'+lstPriceBooks);
        for(PriceBookWrapper objWrapper : lstPriceBooks){
            if(objWrapper.isChecked){
                lstOppItems.add(new OppLineItemWrapper(objWrapper.objPriceBook.Product2.Name, opp.Id, objWrapper.objPriceBook.Id));
                
                productSearched=true;
            }
        }   //  end of for-each Wrapper
    }   //  end of selectProducts

    private void getPriceBookOptions(){
        //Id profileId = userInfo.getProfileId();
        
        
        system.debug('****inside getPriceBookOptions method*****');
        Id roleId = userInfo.getUserRoleId();
        string priceBookName = '';
        system.debug('****inside getPriceBookOptions method1*****');
        string roleName = [SELECT Id, Name FROM UserRole WHERE Id =:roleId].Name;
        system.debug('****inside getPriceBookOptions method2*****');
        //List<SF1_Role_Pricebook__c> mcs = SF1_Role_Pricebook__c.getall().values();
        for(SF1_Role_Pricebook__c cs : SF1_Role_Pricebook__c.getall().values()){
        system.debug('****inside for loop for custom setting*****');
            if(cs.Role__c == roleName){
                priceBookName = cs.PriceBook__c;
                
                system.debug('****inside if block for custom setting*****'+priceBookName );
            }
        }
        //SF1_PriceBook_Profile__c cs = SF1_PriceBook_Profile__c.getInstance(profileId);
        
        
        list<string> setPriceBookName = priceBookName.split(',');
        
        lstPriceBookOptions = new List<SelectOption>();
         system.debug('****setPriceBookName line 177 *****'+setPriceBookName  );
        for(Pricebook2 objPriceBook : [SELECT Id, Name FROM Pricebook2 WHERE Name =:setPriceBookName]){
            lstPriceBookOptions.add(new SelectOption(objPriceBook.Id, objPriceBook.Name));
            system.debug('****objPriceBookline 180*****'+objPriceBook);
        }
         system.debug('****lstPriceBookOptions line 182*****'+lstPriceBookOptions);
         system.debug('****Pricebook Id is line 183*****'+pricebookId);
    }   //  end of getPriceBookOptions
    
    private void setProductSearchLists(){
        
        lstFilterFields = new List<SelectOption>();
        lstFilterFields.add(new SelectOption('',' --NONE-- '));
        lstFilterFields.add(new SelectOption('price_book_name','Price Book Name'));
        lstFilterFields.add(new SelectOption('active','Active (Price Book)'));
        lstFilterFields.add(new SelectOption('product_name','Product Name'));
        lstFilterFields.add(new SelectOption('product_code','Product Code'));
        lstFilterFields.add(new SelectOption('product_family','Product Family'));
        
        
    }   //  end of setProductSearchLists
    
    private void createPriceBookWrapperObjects(list<PriceBookEntry> lstPBEntries){
        lstPriceBooks = new list<PriceBookWrapper>(); 
        
        for(PriceBookEntry objPB : lstPBEntries){
            lstPriceBooks.add(new PriceBookWrapper(false, objPB));
        }   //  end of for-each
    }   //  end of createPriceBookWrapperObjects
    
    class PriceBookWrapper{
        public boolean isChecked { get; set; }
        public PriceBookEntry objPriceBook { get; set; }
        
        public PriceBookWrapper(){
            isChecked=false;
        }
        
        public PriceBookWrapper(boolean pIsChecked, PriceBookEntry pPriceBook){
            isChecked = pIsChecked;
            objPriceBook = pPriceBook;
        }
    }   //  end of class
    
    class OppLineItemWrapper{
        public decimal premium { get; set; }
        public string productName { get; set; }
        public OpportunityLineItem opptyLineItem {get;set;}
        
        public OppLineItemWrapper(string pProductName, Id OpportunityId, Id pPriceBookEntryId){
            
            productName = pProductName;
            system.debug('*****product name****'+productName );
            opptyLineItem = new OpportunityLineItem(OpportunityId = OpportunityId, PriceBookEntryId = pPriceBookEntryId);
            
        }
        
    }   //  end of class
    
}   //  end of SF1AddProductCC

Test class
@isTest (SeeAllData = true)
private class TestSF1AddProductCC {
    
    static Account objAcc;
    static Opportunity objOpp;
    static Profile objProfile=null;
    static UserRole objRole=null;
    static User objUser=null;
    private static Product2  oProd;
    private static PricebookEntry oPBE;
    
    
    static ApexPages.StandardController stdController=null;
    
    
    static testMethod void ZoneTestMethod(){
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GVWS Sales Profile'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Executive Vice President' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;           
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
            PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
            PermissionSetAssignment psa = new PermissionSetAssignment();
            psa.AssigneeId = objUser.Id;
            psa.PermissionSetId = psZONEGVWS .Id;
        
            insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GVWS Employer'].id;
         
            
             objAcc = new Account(Name='Test Account',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect', 
                                  ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
  /*   //   }
           
   // }
     //    static testMethod  void ZoneTestMethod(){ 
             //User u= [Select id,name,email,profile.name from user where lastname = 'TestLast'];
        //    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
       //      system.debug('*****u*****'+u);
         //   System.RunAs(thisUser) {
         //  List<Account> accList1 = [Select id from account];*/
            
            Id recOppId =[select id from recordtype where name ='GVWS Zone Opportunity'].id;
  //        system.debug('*******objrecOppIdAcc*****'+recOppId);
                objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                                       AccountId=objAcc.id,
                                        //Market_Segment__c='RM',
                                       // Distribution_Channel__c='Broker',
                                        Direct__c = true,
                                        CloseDate=System.today(),
                                        StageName='Submitted',
                                        recordtypeId =  recOppId 
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
            
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
        
    }
    static testMethod  void NATestMethod(){ 
            User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GVWS Sales Profile'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Executive Vice President' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
            PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_National_Accounts_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
            PermissionSetAssignment psa = new PermissionSetAssignment();
            psa.AssigneeId = objUser.Id;
            psa.PermissionSetId = psZONEGVWS .Id;
        
            insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GVWS Employer'].id;
         
            
             objAcc = new Account(Name='Test Account',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect', 
                                  ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
  /*   //   }
           
   // }
     //    static testMethod  void ZoneTestMethod(){ 
             //User u= [Select id,name,email,profile.name from user where lastname = 'TestLast'];
        //    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
       //      system.debug('*****u*****'+u);
         //   System.RunAs(thisUser) {
         //  List<Account> accList1 = [Select id from account];*/
            
            Id recOppId =[select id from recordtype where name ='GVWS National Accounts Opportunity'].id;
  //        system.debug('*******objrecOppIdAcc*****'+recOppId);
                objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                                       AccountId=objAcc.id,
                                        //Market_Segment__c='RM',
                                       // Distribution_Channel__c='Broker',
                                        Direct__c = true,
                                        CloseDate=System.today(),
                                        StageName='Submitted',
                                        recordtypeId =  recOppId 
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
      
    }
static testMethod void CustomTestMethod(){
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GEB Australia Marketing'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Australia Head of Sales and Pricing' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;           
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
           // PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
           // PermissionSetAssignment psa = new PermissionSetAssignment();
           // psa.AssigneeId = objUser.Id;
           // psa.PermissionSetId = psZONEGVWS .Id;
        
           // insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GEB Australia Employer'].id;
         
            
            objAcc = new Account(Name='Test Australia',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect',
                                 ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
 
            
           Id recOppId =[select id from recordtype where name ='GEB Australia Employer Opportunity'].id;
  //Account acc= [select id,name from account where member__c];
               objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                         //            AccountId=objAcc.id,
                                     Market_Segment__c = 'Local',
                                     Business_Type__c = 'Pooled',
                                     //  Solution_Type__c = 'Captive',
                                    //   Type = 'Prospect',
                                    //   Member__c = objAcc.id,
                                     type = 'New Business',
                                     Type_Of_Quote__c = 'Direct',
                                       Effective_Date__c = System.today(),
                                       Due_Date__c = System.Today(),
                                      //  Direct__c = true,
                                        CloseDate=System.today(),
                                        Quote_Received_Date__c = System.Today(),
                                        Super_Ordinary__c = 'Ordinary',
                                        StageName='Target'
                                       // recordtypeId =  recOppId 
                                      
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
             Id roleId = userInfo.getUserRoleId();
             string roleName = [SELECT Id, Name FROM UserRole WHERE Id =:roleId].Name;
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
        
    }
   
     /*    static testMethod void testConstructor() {
        setup();
        system.runAs(objUser){
            Test.startTest();
            
            
            
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
            
            Test.stopTest();
        } 
         }*/
  
    
        
    
    
    
    
}   //  end of TestSF1AddProductCC

I am facing problem with code coverage . Till now the coverage is 50%(51/101) . Can anyone help with this
Hi,
Is there a way by which i  can convert CallDurationInSeconds field into minutes provided the new field should not be in text format.
I have tried with
DATETIMEVALUE(TEXT( FLOOR(MOD( CallDurationInSeconds ,3600)/60)) + ":" + TEXT(MOD(MOD( CallDurationInSeconds ,3600),60)))

But it does not work,
Also i have tried with number formula type 
CallDurationInSeconds/60

which gives me a result of 1.10 when i have 66 seconds..But i want 1:06 for 66 seconds
Please help..!

Hi,
 Can anyone help me with this:
I want to give an alert message when user tries to save the task.
Looks simple, But the problem here is that when user first saves the record it gets redirected to opportunity page, and when user checks the task by clicking on the saved task, then he is able to see the popup.
Is there any way by which i can do this.
I know i cannot override the save button on the edit page of task.

Any other suggestion by which user can view the popup is welcome.
What i came up with is if i can redirecty the page back to task detail page after saving rather than opportunity page?..

Hi,

I have a requirement where I need to add validation rule(saying that a field is blank), but that validation should fire if in approval process the stage gets to in review/ or the approver is the Queue of the assigned approver.

I tried using validation rule, but it seems it is not achievable via validation rule.
It seems I need to write a trigger and use StepsAndWorkitems to get the actorId.

Can someone please guide me on how to achive this requirement?
 
How can I hide the User Profile Menu ui from Customer Service community layout. I have removed the search via CSS but I cant create a CSS to remove the Profile Menu UI

 
Hi All,

I have a trigger which does not allow changing of parent record status to implemented till the time child record status is implemented.
Below is the trigger for the same:
trigger RequirementStatusUpdate on Requirement__c (before update) {
	
    Set<Id> setRequirement = new Set<Id>();

    for(Requirement__c rm : trigger.new)
        if(rm.Status__c == 'Implemented')
            setRequirement.add(rm.Id);

    Map<Id, List<System_Action__c>> mapCaseToBuildCard
        = new Map<Id, List<System_Action__c>>();

    for(
        System_Action__c iCard :
        [
            SELECT
                Id, Requirement__c
            FROM
                System_Action__c
            WHERE 
                Requirement__c IN :setRequirement AND
                Status__c != 'Done/Tested'
        ]
    ){
        if(
            !mapCaseToBuildCard.containsKey(
                iCard.Requirement__c
            )
        ){
            mapCaseToBuildCard.put(
                iCard.Requirement__c,
                new List<System_Action__c>{
                    iCard
                }
            );
        }
        else{
            mapCaseToBuildCard.get(
                iCard.Requirement__c
            ).add(iCard);
        }
    }

    for(Requirement__c rm : trigger.new){
        if(rm.Status__c == 'Implemented'){
            if(
                mapCaseToBuildCard.containsKey(rm.Id) &&
                mapCaseToBuildCard.get(
                    rm.Id
                ).size() > 0
            ){
                rm.addError(
                    'You cannot Change the Status to implemented this Requirement. ' + 
                    'There are Open Build Card' + 
                    ' under this Requirement.'
                );
            }
        }
    }
}
Requirement: Parent Object
System Action: Child Object

In test class, so far I have created a dummy Requirement object data and the System Action object data.
but unable to proceed forward with the coverage.
Could you please suggest how exactly I need to cover the code coverage for data presnt in set and checking the if logic criteria.

So far I have written:
@isTest
public class RequirementStatusUpdateTest {
	static testMethod void RequirementStatusUpdateTest(){
    	Recordtype rname = [Select id, name from recordtype where name = 'SFDC Requirement'];
        List<Requirement__c> Req= new List<Requirement__c>();
        //Set up user
        User u1 = [SELECT Id,Name FROM User WHERE GE_ES_SSO__c='502690635'];
      //  Initiative_Project__c VerticalTeam = [select id from Initiative_Project__c where id = 'a0GC000000Liwkw' limit 1];
        
        //Run As U1
        System.runAs(u1){
            test.startTest();
            
            try{
//parent record
            Requirement__c rObj = new Requirement__c(
                RecordTypeid = rname.id,
                Requirement_Type1__c = 'Production Change Request',
                SFDC_Project__c = 'a0GC000000Liwkw',
                Development_Ownership__c= 'P&W > HQ',
                User_Story_Name__c = 'Test class coverage class',
                Tier_2_P_L__c = 'HQ',
                Target_Release__c= 'TBD',
                Prioritization_P_L__c= 'P&W Power Services',
                SFDC_P_L_Owner__c=u1.Id,
                User_Story__c='Test',
                Release__c='TBD1',
                Status__c = 'Draft');
            insert rObj;
            
            

//child record
            System_Action__c BCObj = new System_Action__c();
            BCObj.Requirement__c = rObj.id;
            BCObj.System_Action_Name__c = 'Test coverage';
            BCObj.Status__c = 'Draft';
            insert BCObj;
             
                
                
              
				Set<Requirement__c> setRequirement = new Set<Requirement__c>();
				setRequirement.add(rObj);
                
                
                rObj.Status__c = 'Implemented';
                Update rObj;
            
        
    }
            catch(Exception e){
         
              
}
}
}

Thanks in advance.

Sarthak
We had a release 3 month back.And few picklist values were changed(few were removed and few were added).
Also few picklist field are having history tracking on, and few are not having the field history on. (Fields are under Opportunity Object)

Is there a way to find all the old picklist values that were part of the picklist field before the release ?
I tried to find using OpportunityFieldHistory but the data was not accurate somehow
Thanks in Advance.
Hi,

I have a requirement where I need to add validation rule(saying that a field is blank), but that validation should fire if in approval process the stage gets to in review/ or the approver is the Queue of the assigned approver.

I tried using validation rule, but it seems it is not achievable via validation rule.
It seems I need to write a trigger and use StepsAndWorkitems to get the actorId.

Can someone please guide me on how to achive this requirement?
 
Apex class
public with sharing class SF1AddProductCC {
    
    public String recordType { get; set;} 
    public boolean priceBookSelected { get; set; }
    public boolean GVWSOpp { get; set; }
    public boolean nonGVWSOpp { get; set; }

    public Opportunity opp {get; set;}
    public list<PriceBookWrapper> lstPriceBooks { get; set; }
    public list<OppLineItemWrapper> lstOppItems { get; set; }
    
    public boolean productSearched { get; set; }
    public List<SelectOption> lstPriceBookOptions{ get; set; }
    public String priceBookId { get; set; }
    
    
    public string keyword { get; set; }
    public List<SelectOption> lstFilterFields{ get; set; }
    public string field { get; set; }
    private ApexPages.StandardController standardController; 
    
    
    
    public SF1AddProductCC(ApexPages.StandardController standardController){
        
        
        this.standardController = standardController;
        opp = (Opportunity) standardController.getRecord();
        
        recordType = ApexPages.currentPage().getParameters().get('recordType');
        
        priceBookSelected = false;
        productSearched = false;
               
String recordtypename = [select recordtype.name from opportunity where id =: opp.id limit 1].recordtype.name;
        system.debug('recordtypename#####'+ recordtypename);

if(recordtypename == 'GVWS Zone Opportunity' || recordtypename == 'GVWS National Accounts Opportunity')
{
GVWSOpp = true;
nonGVWSOpp = false;
   }
else
{
GVWSOpp = false;
nonGVWSOpp = true;
}

        if(GVWSOpp == false && nonGVWSOpp == true)
        {    
         //TODO: Check if the PriceBook is already selected
        system.debug('****before getPriceBookOptions method*****');
        getPriceBookOptions();
        system.debug('****after getPriceBookOptions method*****');
        }
        setProductSearchLists();
          

        
        /*
            If there is only one Pricebook2 entry, we set the selected
            Pricebook2 and then call save.
        */
        
         if(GVWSOpp == false && nonGVWSOpp == true)
            {
        if(lstPriceBookOptions.size() == 1){
          
            priceBookId = lstPriceBookOptions[0].getValue();
            system.debug('********priceBookId for Other*********'+priceBookId );
            }
            }      
            else if (GVWSOpp == true && nonGVWSOpp == false)
            {
             if(recordtypename == 'GVWS Zone Opportunity')
             {
             priceBookId = [SELECT Id FROM Pricebook2 WHERE Name = 'GVWS Zone Price Book'].Id;
             system.debug('********priceBookId for Zone*********'+priceBookId );
             }
             else if (recordtypename == 'GVWS National Accounts Opportunity')
             {
             pricebookid =  [SELECT Id FROM Pricebook2 WHERE Name = 'GVWS NA Price Book'].Id  ;                                 
             system.debug('********priceBookId for NA*********'+priceBookId );
             }    
                  system.debug('Pricebook Id is'+pricebookId);
      
            }
            save();
        }
        
       //  end of constructor
    
    
    public void save(){
        list<PriceBookEntry> lstPBEntries = new list<PriceBookEntry>();
        priceBookSelected=true;
        
        lstPBEntries = [Select Id, Name, pricebook2.Name, product2.Name, product2.Description, product2.family 
                                            from PricebookEntry where pricebook2Id = :priceBookId  AND product2.IsActive = true and pricebook2.IsActive = true and IsActive = true];
        createPriceBookWrapperObjects(lstPBEntries);
         
    }   //  end of save
    
    public pageReference saveOpptyLineItem(){
        
        list<OpportunityLineItem>lstOpptyLineItems = new list<OpportunityLineItem>();
        for(OppLineItemWrapper objOppLineItemWrap :lstOppItems ){
            
            objOppLineItemWrap.opptyLineItem.TotalPrice = objOppLineItemWrap.premium;
            lstOpptyLineItems.add(objOppLineItemWrap.opptyLineItem);
        }
        
        if(lstOpptyLineItems.size() > 0){
            
            insert lstOpptyLineItems;
           
        }
        
        
// Rahul Mehta Commented below two lines for INC00019824 - SF1 issue
       // pageReference page = new pageReference('/'+ opp.Id);
       // return page;
        return Null;
    }
    
    public void cancel(){
        
    }   //  end of cancel
    
    public void searchProducts(){
        list<PriceBookEntry> lstPBEntries = new list<PriceBookEntry>();
        system.debug('Pricebook Id is'+pricebookId);
        string likeStr = '%'+ keyword +'%';
        lstPBEntries = [SELECT Id, Name, pricebook2.Name, product2.Name, product2.Description, product2.family 
                                            FROM PricebookEntry 
                                            WHERE pricebook2Id = :priceBookId 
                                              AND product2.Name like :likeStr
                                              AND product2.IsActive = true ];
        createPriceBookWrapperObjects(lstPBEntries);
        
    }   //  end of searchProducts
    
    public void selectProducts(){
        lstOppItems = new list<OppLineItemWrapper>();
         system.debug('*****lstPriceBooks********'+lstPriceBooks);
        for(PriceBookWrapper objWrapper : lstPriceBooks){
            if(objWrapper.isChecked){
                lstOppItems.add(new OppLineItemWrapper(objWrapper.objPriceBook.Product2.Name, opp.Id, objWrapper.objPriceBook.Id));
                
                productSearched=true;
            }
        }   //  end of for-each Wrapper
    }   //  end of selectProducts

    private void getPriceBookOptions(){
        //Id profileId = userInfo.getProfileId();
        
        
        system.debug('****inside getPriceBookOptions method*****');
        Id roleId = userInfo.getUserRoleId();
        string priceBookName = '';
        system.debug('****inside getPriceBookOptions method1*****');
        string roleName = [SELECT Id, Name FROM UserRole WHERE Id =:roleId].Name;
        system.debug('****inside getPriceBookOptions method2*****');
        //List<SF1_Role_Pricebook__c> mcs = SF1_Role_Pricebook__c.getall().values();
        for(SF1_Role_Pricebook__c cs : SF1_Role_Pricebook__c.getall().values()){
        system.debug('****inside for loop for custom setting*****');
            if(cs.Role__c == roleName){
                priceBookName = cs.PriceBook__c;
                
                system.debug('****inside if block for custom setting*****'+priceBookName );
            }
        }
        //SF1_PriceBook_Profile__c cs = SF1_PriceBook_Profile__c.getInstance(profileId);
        
        
        list<string> setPriceBookName = priceBookName.split(',');
        
        lstPriceBookOptions = new List<SelectOption>();
         system.debug('****setPriceBookName line 177 *****'+setPriceBookName  );
        for(Pricebook2 objPriceBook : [SELECT Id, Name FROM Pricebook2 WHERE Name =:setPriceBookName]){
            lstPriceBookOptions.add(new SelectOption(objPriceBook.Id, objPriceBook.Name));
            system.debug('****objPriceBookline 180*****'+objPriceBook);
        }
         system.debug('****lstPriceBookOptions line 182*****'+lstPriceBookOptions);
         system.debug('****Pricebook Id is line 183*****'+pricebookId);
    }   //  end of getPriceBookOptions
    
    private void setProductSearchLists(){
        
        lstFilterFields = new List<SelectOption>();
        lstFilterFields.add(new SelectOption('',' --NONE-- '));
        lstFilterFields.add(new SelectOption('price_book_name','Price Book Name'));
        lstFilterFields.add(new SelectOption('active','Active (Price Book)'));
        lstFilterFields.add(new SelectOption('product_name','Product Name'));
        lstFilterFields.add(new SelectOption('product_code','Product Code'));
        lstFilterFields.add(new SelectOption('product_family','Product Family'));
        
        
    }   //  end of setProductSearchLists
    
    private void createPriceBookWrapperObjects(list<PriceBookEntry> lstPBEntries){
        lstPriceBooks = new list<PriceBookWrapper>(); 
        
        for(PriceBookEntry objPB : lstPBEntries){
            lstPriceBooks.add(new PriceBookWrapper(false, objPB));
        }   //  end of for-each
    }   //  end of createPriceBookWrapperObjects
    
    class PriceBookWrapper{
        public boolean isChecked { get; set; }
        public PriceBookEntry objPriceBook { get; set; }
        
        public PriceBookWrapper(){
            isChecked=false;
        }
        
        public PriceBookWrapper(boolean pIsChecked, PriceBookEntry pPriceBook){
            isChecked = pIsChecked;
            objPriceBook = pPriceBook;
        }
    }   //  end of class
    
    class OppLineItemWrapper{
        public decimal premium { get; set; }
        public string productName { get; set; }
        public OpportunityLineItem opptyLineItem {get;set;}
        
        public OppLineItemWrapper(string pProductName, Id OpportunityId, Id pPriceBookEntryId){
            
            productName = pProductName;
            system.debug('*****product name****'+productName );
            opptyLineItem = new OpportunityLineItem(OpportunityId = OpportunityId, PriceBookEntryId = pPriceBookEntryId);
            
        }
        
    }   //  end of class
    
}   //  end of SF1AddProductCC

Test class
@isTest (SeeAllData = true)
private class TestSF1AddProductCC {
    
    static Account objAcc;
    static Opportunity objOpp;
    static Profile objProfile=null;
    static UserRole objRole=null;
    static User objUser=null;
    private static Product2  oProd;
    private static PricebookEntry oPBE;
    
    
    static ApexPages.StandardController stdController=null;
    
    
    static testMethod void ZoneTestMethod(){
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GVWS Sales Profile'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Executive Vice President' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;           
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
            PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
            PermissionSetAssignment psa = new PermissionSetAssignment();
            psa.AssigneeId = objUser.Id;
            psa.PermissionSetId = psZONEGVWS .Id;
        
            insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GVWS Employer'].id;
         
            
             objAcc = new Account(Name='Test Account',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect', 
                                  ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
  /*   //   }
           
   // }
     //    static testMethod  void ZoneTestMethod(){ 
             //User u= [Select id,name,email,profile.name from user where lastname = 'TestLast'];
        //    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
       //      system.debug('*****u*****'+u);
         //   System.RunAs(thisUser) {
         //  List<Account> accList1 = [Select id from account];*/
            
            Id recOppId =[select id from recordtype where name ='GVWS Zone Opportunity'].id;
  //        system.debug('*******objrecOppIdAcc*****'+recOppId);
                objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                                       AccountId=objAcc.id,
                                        //Market_Segment__c='RM',
                                       // Distribution_Channel__c='Broker',
                                        Direct__c = true,
                                        CloseDate=System.today(),
                                        StageName='Submitted',
                                        recordtypeId =  recOppId 
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
            
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
        
    }
    static testMethod  void NATestMethod(){ 
            User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GVWS Sales Profile'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Executive Vice President' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
            PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_National_Accounts_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
            PermissionSetAssignment psa = new PermissionSetAssignment();
            psa.AssigneeId = objUser.Id;
            psa.PermissionSetId = psZONEGVWS .Id;
        
            insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GVWS Employer'].id;
         
            
             objAcc = new Account(Name='Test Account',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect', 
                                  ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
  /*   //   }
           
   // }
     //    static testMethod  void ZoneTestMethod(){ 
             //User u= [Select id,name,email,profile.name from user where lastname = 'TestLast'];
        //    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
       //      system.debug('*****u*****'+u);
         //   System.RunAs(thisUser) {
         //  List<Account> accList1 = [Select id from account];*/
            
            Id recOppId =[select id from recordtype where name ='GVWS National Accounts Opportunity'].id;
  //        system.debug('*******objrecOppIdAcc*****'+recOppId);
                objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                                       AccountId=objAcc.id,
                                        //Market_Segment__c='RM',
                                       // Distribution_Channel__c='Broker',
                                        Direct__c = true,
                                        CloseDate=System.today(),
                                        StageName='Submitted',
                                        recordtypeId =  recOppId 
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
      
    }
static testMethod void CustomTestMethod(){
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        
        System.runAs (thisUser){
            objProfile = [SELECT Id, Name FROM Profile WHERE Name='GEB Australia Marketing'];
            objRole = [SELECT Id, Name FROM UserRole WHERE Name='Australia Head of Sales and Pricing' LIMIT 1];
            objUser = new User(FirstName = 'TestFirst',  
                               LastName = 'TestLast',
                               Username = 'TestFirst.TestLast' + '@testing.com',
                               CommunityNickname = 'testlast',
                               IsActive = true,
                               UserRoleId = objRole.Id,
                               Email = 'testuser@testing.com', 
                               Alias = 'tusr', 
                               TimeZoneSidKey = 'America/New_York' , 
                               LocaleSidKey = 'en_US', 
                               EmailEncodingKey = 'UTF-8', 
                               ProfileId = objProfile.Id, 
                               LanguageLocaleKey = 'en_US',
                               EBS_Division__c = 'Other',
                               EBS_Channel__c = 'Other'
                               );
            
            insert objUser;           
            
            //PermissionSet ps = [SELECT ID From PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
            //insert new PermissionSetAssignment(AssigneeId = objUser.id, PermissionSetId = ps.Id );
           // PermissionSet psZONEGVWS = [SELECT Id FROM PermissionSet WHERE Name = 'GVWS_Zone_Permission_Set'];
          
            //Assign the above gvwsusr inserted user for the above Permission Set.
           // PermissionSetAssignment psa = new PermissionSetAssignment();
           // psa.AssigneeId = objUser.Id;
           // psa.PermissionSetId = psZONEGVWS .Id;
        
           // insert psa;
        }
        System.RunAs(objUser){
             test.startTest();
             
             List<Account> accList = new List<Account>();
             Id recId =[select id from recordtype where name = 'GEB Australia Employer'].id;
         
            
            objAcc = new Account(Name='Test Australia',
                                  RecordtypeId=recId, 
                                  Type = 'Prospect',
                                 ownerid = objUser.id
                                  );  
             
             insert objAcc ;
       
             
 
            
           Id recOppId =[select id from recordtype where name ='GEB Australia Employer Opportunity'].id;
  //Account acc= [select id,name from account where member__c];
               objOpp = new Opportunity(Name='Test Opp',
                                     ownerid = objUser.id,
                         //            AccountId=objAcc.id,
                                     Market_Segment__c = 'Local',
                                     Business_Type__c = 'Pooled',
                                     //  Solution_Type__c = 'Captive',
                                    //   Type = 'Prospect',
                                    //   Member__c = objAcc.id,
                                     type = 'New Business',
                                     Type_Of_Quote__c = 'Direct',
                                       Effective_Date__c = System.today(),
                                       Due_Date__c = System.Today(),
                                      //  Direct__c = true,
                                        CloseDate=System.today(),
                                        Quote_Received_Date__c = System.Today(),
                                        Super_Ordinary__c = 'Ordinary',
                                        StageName='Target'
                                       // recordtypeId =  recOppId 
                                      
                                        );
               
          //  oppList.add(objOpp);
          system.debug('*******objOpp*****'+objOpp);
               // system.debug('*******objAcc.id*****'+objAcc.id);
            insert objOpp;
           system.debug('*******objOpp*****'+objOpp); 
             Id roleId = userInfo.getUserRoleId();
             string roleName = [SELECT Id, Name FROM UserRole WHERE Id =:roleId].Name;
           test.stopTest();
            stdController = new ApexPages.StandardController(objOpp); 
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
             
             
        }
        
    }
   
     /*    static testMethod void testConstructor() {
        setup();
        system.runAs(objUser){
            Test.startTest();
            
            
            
            SF1AddProductCC ext = new SF1AddProductCC(stdController);
            
            Test.stopTest();
        } 
         }*/
  
    
        
    
    
    
    
}   //  end of TestSF1AddProductCC

I am facing problem with code coverage . Till now the coverage is 50%(51/101) . Can anyone help with this
Hi,
Is there a way by which i  can convert CallDurationInSeconds field into minutes provided the new field should not be in text format.
I have tried with
DATETIMEVALUE(TEXT( FLOOR(MOD( CallDurationInSeconds ,3600)/60)) + ":" + TEXT(MOD(MOD( CallDurationInSeconds ,3600),60)))

But it does not work,
Also i have tried with number formula type 
CallDurationInSeconds/60

which gives me a result of 1.10 when i have 66 seconds..But i want 1:06 for 66 seconds
Please help..!
Hi All,

We have a requirement to display popup window on the edit page(before click on save button) on opportunity Standard page based on selection of particular picklist value.

Can anyone aware on this requirement.Please sugest me how to overcome from this scenario.

Many Thanks in Advance,

Regards,
Surekha