• Brad Barrowes
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 6
    Replies

Hi all,

I am facing an issue in retrieving queue name by querying the QSObject.

 

List<QueueSobject> lstQueueName = [Select Id, SobjectType, QueueId,Queue.Name from QueueSobject where SobjectType = 'Case' AND QueueId =: '00G30000002conp'];
system.debug(lstQueueName[0].queue.Name+'---');

 

The above query returns me the Queue Label but wat i need is the Queue name as u can see on the UI when u open any Queue.

 

Waiting for a quick reply,

Thanks,
Sridhar

 

There seems to be nothing in the Apex guides on how to test a set controller.  This method runs when a button is clicked on a custom object list view and processes the records selected from the list view.

 

How do I test it?  I can't figure out how to get any records "selected" in the StandardSetController.

 

 

public with sharing class replacerRunAllSelectedRulesController{

    ApexPages.StandardSetController setCon;
    private PageReference savePage;

    public replacerRunAllSelectedRulesController(ApexPages.StandardController controller) {
        //Not sure why this is needed...
    }//replacerRunAllSelectedRulesController

    public replacerRunAllSelectedRulesController(ApexPages.StandardSetController controller) {
        setCon=controller;
        List<Replacer__c> selectedRules=new List<Replacer__c>();
    }//replacerRunAllSelectedRulesController
    

    public PageReference runSelectedRules(){
        List<Replacer__c> selectedRules=new List<Replacer__c>();
        for(sObject s: setCon.getSelected()){
            Replacer__c r=(Replacer__c)s;
            selectedRules.add(r);
        }//for 1
        String objectName='';
        Boolean sendEmail=TRUE;
        
        if(selectedRules.size()==0){
        	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 
        	'You must select at least one rule.  Please go back and select a rule by checking the checkbox and try again.'));        
        }else{
	        
	        Integer numJobsCantBeRunNow=replacerExecute.replacerQueueBatchJobs(objectName, selectedRules, sendEmail);
	        if(numJobsCantBeRunNow==0){
	            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.CONFIRM,'Replacement has begun.  This can take ~10-30 minutes for each 10,000 records.  You will receive 1 email confirmation for each different object as all rules for one object are run together in one job.');
	            ApexPages.addMessage(myMsg);
	        }else{
	            //else throw an error that they need to select fewer rules to run right now
	            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'The selected rules cannot be run now as they would exceed your companies batch job limit of 5.  One job is created for each different object.  Please unselect ' + numJobsCantBeRunNow + ' object\'s rules and try again.  To view the batch queue, click Setup-->Monitoring-->Apex Jobs'));
	        }//if 2
        }//if 1
        
        return ApexPages.CurrentPage();
    }//runSelectedRules
    
}//replacerRunAllSelectedRulesController

 

Here's where I'm at - I have the controller assigned, but can't figure out how to select the records in the set controller:

 

 

public static testMethod void verifyListViewRunSelectedRulesButton() {
	Boolean deleteReplacers=TRUE;
        Boolean deleteQueuedJobs=FALSE;
        Boolean deleteFieldList=FALSE;
        Boolean deleteTestData=TRUE;
        Boolean deleteJobHistory=FALSE;
        Boolean abortBatchJobs=FALSE;
        //There should be zero replacers after this method runs
        deleteTestData(deleteReplacers, deleteQueuedJobs, deleteFieldList, deleteTestData, deleteJobHistory, abortBatchJobs);

        //Make 1 active rule so that a preview can be shown
        Boolean rActive=TRUE;
        String rObjectName='test__c';
        String rFieldName='picklist__c';
        String rFind='a';
        String rValue='b';
        List<replacer__c> rules=new List<replacer__c>();
        rules.add(createRule(rActive, rObjectName, rFieldName, rFind, rValue));
        rFieldName='text__c';
        rules.add(createRule(rActive, rObjectName, rFieldName, rFind, rValue));
        insert rules;

        Long numRecords=2;
        Date dat=date.today();
        DateTime datTim=dateTime.now();
        Decimal dec=0.123;
        String em='a@a.com';
        String ph='415-555-1234';
        String pick='a';            
        String text='a';
        String ur='http://www.google.com';

        //Insert some test data so we can play with the controller
        List<test__c> ts=createTestRecords(numRecords, dat, datTim, dec, em, ph, pick, text, ur); 
        pick='c';
        List<test__c> ts2=createTestRecords(1, dat, datTim, dec, em, ph, pick, text, ur);
        
        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(rules);
        replacerRunAllSelectedRulesController scExt = new replacerRunAllSelectedRulesController(sc);
	//How do I select both "rules"?	
        test.StartTest();
            scExt.runSelectedRules();
        test.stopTest();

	List<test__c> results=[SELECT Id, picklist__c FROM test__c WHERE Id IN: ts];
        for(test__c t: results){
            system.assertEquals(rValue, t.picklist__c);
        }//for

        List<test__c> results2=[SELECT Id, picklist__c FROM test__c WHERE Id IN: ts2];
        for(test__c t: results2){
            system.assertEquals(pick, t.picklist__c);
        }//for
        
    }//verifyListViewRunSelectedRulesButton

 

 

 

 

 

I need some assistance making a connection.  I would like to create a custom vf page to create the line items of an Opportunity. I follow the standard process and I see the lineitem.jsp page which I want to replace with a custom page, but don't understand the relationship to perform operation.

  • January 21, 2011
  • Like
  • 0

Hi,

 

I have created a visualforce page to upload an attachment for a custom object. Now I simply want to create a new field "Type of Attachment" (Drop Down Field) with that attachment .. just to make my user understand that what kind of attachment it is.... and that Field ofcourse should get visible inside Notes and Attachment related list......

 

Can it be done....

Hi,

I am using a visualforce page and would like to add some error messages into it for example if some field is empty etc...... I do not want to set a validation rule, but would like to work on the save function in the controller to display the error message. Would be of great help if someone could point me out the direction to do that.

I have one more question relating to displaying an output in visualforce. I have a lookup field, it has quantity field too, i would like to populate the quantity from the master object, if i change the lookup the value for quantity should also change respectively, I tried formulas but they effect after save, I would like to have immediate change.

Thanks

KD 

  • June 08, 2009
  • Like
  • 1

Hi,

I am using a visualforce page and would like to add some error messages into it for example if some field is empty etc...... I do not want to set a validation rule, but would like to work on the save function in the controller to display the error message. Would be of great help if someone could point me out the direction to do that.

I have one more question relating to displaying an output in visualforce. I have a lookup field, it has quantity field too, i would like to populate the quantity from the master object, if i change the lookup the value for quantity should also change respectively, I tried formulas but they effect after save, I would like to have immediate change.

Thanks

KD 

  • June 08, 2009
  • Like
  • 1