• Neha Lund
  • NEWBIE
  • 135 Points
  • Member since 2013

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 75
    Replies
Hi
I am using two kind of objects: Item and Category. They are linked via junction table CategoryItem. So, how to select objects into Map<Category, Item[]>. This map should contain array of items under each category. Thank you in advance.

Hi all, I'm trying to delpoy the Round Robin Assigmnet app that I've tailored to work with leads.

 

Unfortunatly, the test class is failing 1 out of 4 and this means I can't deploy to my production, can you guys help?

 

Here's the whole test class and I've highlighted the line referenced in the error (Class.TestMethodClsLeads1.myTest3: line 217, column 1) in bold. Any ideas?

 

@isTest
private class TestMethodClsLeads1 {

    static testMethod void myTest1() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);

       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       // Second Queue       
       Group testGroup2 = new Group ();
       testGroup2.Name = 'TestQueue2';
       testGroup2.Type = 'Queue';
       insert testGroup2;
       
       QueueSObject testQueue2 = new QueueSObject();
       testQueue2.QueueId = testGroup2.id;
       testQueue2.SObjectType = 'Lead';
       insert testQueue2;


       test.starttest();
        
        //Run test

        //Assign Lead with out any Assignment Groups
        Lead c1 = new Lead (Firstname='testLead', Lastname='testLead', Company='test', Phone='5555555555', Email='test@tester.com',TempOwnerID__c=testGroup2.id, OwnerID=u1.id); //TempOwnerID__c=testGroup2.id,  
        insert c1;
        update c1;
        
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;

         
        //Add bad queue name
        Assignment_Group_Queues__c agqBad = new Assignment_Group_Queues__c(name='Bad Queue',Assignment_Group_Name__c = ag1.id );

        try {
            insert agqBad; 
        } catch (DmlException e){
             System.assert(e.getMessage().contains('CUSTOM_VALIDATION_EXCEPTION'), e.getMessage()); 
        
        } //catch

        test.stoptest();
        
    }
    
    static testMethod void myTest2() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);

       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       // Second Queue       
       Group testGroup2 = new Group ();
       testGroup2.Name = 'TestQueue2';
       testGroup2.Type = 'Queue';
       insert testGroup2;
       
       QueueSObject testQueue2 = new QueueSObject();
       testQueue2.QueueId = testGroup2.id;
       testQueue2.SObjectType = 'Lead';
       insert testQueue2;


       test.starttest();
        
        //Run test
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;        

        //Add Good Queue to Assignment Group
        Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id );
        insert agq1;
        
        
        //Add User to Assignment Groups Users
        Assignment_Groups__c agu1 = new Assignment_Groups__c (User__c = u1.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2009-01-01 21:13:24') );
        insert agu1;

        Lead c2 = new Lead (Firstname='testLead', Status='New', Lastname='testLead', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup2.id , OwnerID=testGroup.id); //Set owner ID to Queue
        insert c2;
        update c2;        

        test.stoptest();
        
    }

    static testMethod void myTest3() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);
        
        User u2;

        try{
          u2 = [select Id from User WHERE IsActive=True AND Profile.Name = 'AMAG Standard User'  LIMIT 1];
        } catch (QueryException qe){
//should run an error test here like above.              
        }


        System.debug(u2);
        


       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       test.starttest();
        
        //Run test        
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;        

        //Add Good Queue to Assignment Group
        Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id );
        insert agq1;
        
         //Add User to Assignment Groups Users
        Assignment_Groups__c agu1 = new Assignment_Groups__c (User__c = u1.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2009-01-01 21:13:24') );
        insert agu1;   

        //Add User to Assignment Groups Users
Assignment_Groups__c agu2 = new Assignment_Groups__c (User__c = u2.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2010-01-01 21:13:24') ); insert agu2; Lead c2 = new Lead (Firstname='testLead', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', OwnerID=testGroup.id); //Set owner ID to Queue insert c2; update c2; Lead c3 = new Lead (Firstname='testLead2', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup.id , OwnerID=testGroup.id); //Set owner ID to Queue insert c3; update c3; Lead c4 = new Lead (Firstname='testLead3', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup.id , OwnerID=testGroup.id); //Set owner ID to Queue insert c4; update c4; test.stoptest(); } static testMethod void myTest4() { // This code runs as the system user User u1; try{ u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator' LIMIT 1]; } catch (QueryException qe){ List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000]; for(User u : users){ if(u.Profile.PermissionsModifyAllData = true){ u1 = u; break; } } } System.debug(u1); //*****Create Queue Group testGroup = new Group (); testGroup.Name = 'TestQueue'; testGroup.Type = 'Queue'; insert testGroup; QueueSObject testQueue = new QueueSObject(); testQueue.QueueId = testGroup.id; testQueue.SObjectType = 'Lead'; insert testQueue; test.starttest(); //Run test //Create Assignment Group Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead'); insert ag1; //Add Good Queue to Assignment Group Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id ); insert agq1; //Test for AG-Queues already assigned to another Assignment Group -- trying to assign a group with a name that already exists.. repeats code above. Assignment_Group_Queues__c agq2 = new Assignment_Group_Queues__c(name=testGroup.Name,Assignment_Group_Name__c = ag1.id ); try { insert agq2; } catch (DmlException e){ System.assert(e.getMessage().contains('CUSTOM_VALIDATION_EXCEPTION'), e.getMessage()); } //catch test.stoptest(); } }

 

 

hello,

Can anyone help

I m new to Salesforce please help.

I have a picklist with some values of fruits in it.

Example:

Apple Grapes Banana etc.

I have sorted these values alphabetically.

But now i want a default value to be added in picklist like example: '--Select value--'

Can i pass this value directly to the constructor to make it default to picklist?

Or should I add it first to the select list.

 

Please help

Thanks.

 

I now have a fewTabs for  visualforce pages on my navigation bar.

 

The problem is that when I choose a page, that page's Tab does not become the active one.

 

What do I do to fix that?

 

Here is a sample page:

<apex:page standardController="Case" extensions="CaseExtension">
<apex:stylesheet value="{/Resources.ForteStyles.css}" />
<style>
.hv{text-align:left;font-size:1.2em; color: #1fbdf2;font-weight:bold;}
</style>
<apex:pageBlock title="My Requests" >
<apex:form >
<apex:dataTable value="{!cases}" var="s" columns="5" cellspacing="15" >
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request?CaseNumber={!s.CaseNumber}">{! s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{! s.Subject}" headerValue="Subject" headerClass="hv" />
<apex:column value="{! s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{! s.Ownerid}" headerValue="Request Owner" headerClass="hv" />
</apex:dataTable>
</apex:form>
</apex:pageBlock>
</apex:page>

  • July 02, 2013
  • Like
  • 0

Hi,

I am new to Salesforce.

Can anyone please help.

 

Below is my VF code:

  <apex:repeat value="{!InnerList}" var="in">
  
          <apex:selectList value="{!in.selectedValue1}" multiselect="false" style="width:200px;" size="1">
        
              <apex:selectOptions value="{!Header}"/>
             
               </apex:selectList>
            
          
          <apex:selectList value="{!in.selectedValue2}" multiselect="false" style="width:200px;" size="1">
               <apex:selectOptions value="{!FieldList}"/>
           
          </apex:selectList>
        
          
          
      </apex:repeat>

 Controller:

 

public class communityCon1234
{

    public list<communityCon1Inner> Innerlist{get;set;}
    
    public class communityCon1Inner
    {
         public string selectedValue1{get;set;}
         public String selectedValue2{set;get;}
           
    }
     public communityCon1234()
    {
       InnerList = new list<communityCon1Inner>();  
       
        
       communityCon1Inner c= new communityCon1Inner();
       
         InnerList.add(c);
     }
}

 And FieldList and Header contains values of drop down.

 Suppose Header contains values like:

 Name

 Student

 Year

 College

 DOJ

 

Using the above code i get the first value as default value i.e. Name in all the listboxes.

I want my listboxes to have Name in the first listbox,Student in the second listbox,year in the third listbox and so on.

I cannot use :

    <apex:selectOptions value="{!Header[in]}"/>

 As var="in" is of type innerlist of a inner class
I cannot remove the inner class as well because it is getting me the values of selectedvalue1 and selectedvalue2.

 

So please help.

Do i use an another repeat tag with var or what?

 

Thanks.

 

 

When data loader is connected via proxy settings, bulk api is resulting in 'server error returned in unknown format'

Please let me know if I am missing anything, profile is System Administrator, bulk api is enabled.
User-added image

And without bulk api it throws an error 'Error writing row'.
Thank you!
Hi
I am using two kind of objects: Item and Category. They are linked via junction table CategoryItem. So, how to select objects into Map<Category, Item[]>. This map should contain array of items under each category. Thank you in advance.

Hi All 

     I am trying to write a test class for this apex class and VF page but im getting this error 

System.NullPointerException: Attempt to de-reference a null objectStack TraceClass.Custom_Account_Lookup_Search.saveAccount: line 42, column 1
Class.Test_Custom_Account_Lookup_Search.test1: line 24, column 1

 how to solve this issue;

 

Test Class:

@isTest(Seealldata = true)
public class Test_Custom_Account_Lookup_Search
{
 Static testmethod void test1()
 {
    PageReference pg = page.Custom_Account_Lookup_Search_page;
    Test.setcurrentPage(pg);    
    //account a = new Account( name='foo' ,BillingStreet ='west',BillingCity ='test') ;
     //insert a;
     Account acc = new Account();
     acc.Name='voltum';
     acc.BillingStreet='Santhom High Road';
     acc.BillingCity='Chennai';
     acc.BillingState='TamilNadu';
     acc.BillingCountry='India';
     //acc.BillingZipPostal='6000028';
     acc.Email__c='perisoft@voltum.com';
     acc.Fax='+49 9134 85 28732';
     acc.Website='http://www.voltum.com.au/';
   insert acc;
     Site__c site = new Site__c();
     ApexPages.StandardController stdController1 = new ApexPages.StandardController(site); 
     Custom_Account_Lookup_Search thecontroller1 = new Custom_Account_Lookup_Search(stdController1);
     thecontroller1.saveAccount();
     
   }
}

 

Aex class:

public with sharing class Custom_Account_Lookup_Search {

public Account account {get;set;} // new account to create
public List<Account> results{get;set;} // search results
public string searchString{get;set;} // search keyword

public Custom_Account_Lookup_Search() {
account = new Account();
// get the current search string
searchString = System.currentPageReference().getParameters().get('lksrch');
runSearch();
}

// performs the keyword search
public PageReference search() {
runSearch();
return null;
}
public Custom_Account_Lookup_Search(ApexPages.StandardController stdController)
{
}
// prepare the query and issue the search command
private void runSearch() {
// TODO prepare query string for complex serarches & prevent injections
results = performSearch(searchString);
}

// run the search and return the records found.
private List<Account> performSearch(string searchString) {

String soql = 'select id, name from account';
if(searchString != '' && searchString != null)
soql = soql + ' where name LIKE \'%' + searchString +'%\'';
soql = soql + ' limit 25';
System.debug(soql);
return database.query(soql);

}

// save the new account record
public PageReference saveAccount() {
insert account;
// reset the account
account = new Account();
return null;
}

// used by the visualforce page to send the link to the right dom element
public string getFormTag() {
return System.currentPageReference().getParameters().get('frm');
}

// used by the visualforce page to send the link to the right dom element for the text box
public string getTextBox() {
return System.currentPageReference().getParameters().get('txt');
}

}

 

VF Page:

<apex:page controller="Custom_Account_Lookup_Search"
title="Search"
showHeader="false"
sideBar="false"
tabStyle="Account"
id="pg">

<apex:form >
<apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

<!-- SEARCH TAB -->
<apex:tab label="Search" name="tab1" id="tabOne">

<apex:actionRegion >
<apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
<apex:inputText id="txtSearch" value="{!searchString}" />
<span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
</apex:outputPanel>

<apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
<apex:pageBlock id="searchResults">
<apex:pageBlockTable value="{!results}" var="a" id="tblResults">
<apex:column >
<apex:facet name="header">
<apex:outputPanel >Name</apex:outputPanel>
</apex:facet>
<apex:outputLink value="javascript&colon;top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:actionRegion>

</apex:tab>

<!-- NEW ACCOUNT TAB -->
<apex:tab label="New Account" name="tab2" id="tabTwo">

<apex:pageBlock id="newAccount" title="New Account" >

<apex:pageBlockButtons >
<apex:commandButton action="{!saveAccount}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageMessages />

<apex:pageBlockSection columns="2">
<apex:repeat value="{!$ObjectType.Account.FieldSets.CustomAccountLookup}" var="f">
<apex:inputField value="{!Account[f]}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:tab>
</apex:tabPanel>
</apex:outputPanel>
</apex:form>
</apex:page>

 

I am not geeting the Visual force page in to override with List of an Custom object. I  Changed my VF page like this

 

<apex:page standardController="Case_Accession__c"  extensions="ExtentionController">

...................My Code..............................

</apex:page>

 

What I am doing wrong ??

 

Regards

Raman

I have created a VF page to display Funds records related to current portal user. In the controller I have written a query to return records, which is working fine but I am not able to return error message if no records exist for that user.Here's the code for VF and apex.

 

=======VF Page======

 

<apex:page controller="CTRL_FundTab" tabStyle="ENT_Fund__c" title="ENT_Fund__c" >
  
    <apex:form id="form" >
    <apex:sectionHeader title="Fund" />
        <apex:pageBlock title="Recent Funds">
                  <apex:pagemessages />
                  <apex:pageBlockTable value="{!funds}" var="row">
                          <apex:column >
                               <apex:facet name="header">Fund Name</apex:facet>
                        
                               <apex:outputLink title="" value="/{!row.id}" >{!row.Name}</apex:outputLink>
                        </apex:column>
                   </apex:pageBlockTable>
        </apex:pageBlock>

    </apex:form>
</apex:page>

 

=======Controller====

 

public class CTRL_FundTab
{

    public CTRL_FundTab()
    {

    }

        public List<ENT_Fund__c> getFunds()
        {
           
            ID contactId = [Select contactid from User where id =: Userinfo.getUserid()].contactId;
            ID AccID  = [Select AccountID from Contact where id =: contactid].AccountId;
            list<ENT_Closing_Phase_Entity__c> cpeLst = [select Id,Name, Account__r.Name,Fund__c,Fund__r.Name from   ENT_Closing_Phase_Entity__c where Account__c =:AccID];
            String ff = cpeLst[0].Fund__r.Name;
            list<ENT_Fund__c> funLst = [select Id,Name from ENT_Fund__c where Name =: ff];
            system.debug('$$$$$$$'+funLst.size());
            system.debug('$$$$$$$'+funLst[0].name);
            return funLst;
   
           


           
       }   

}

 

When I try to return Apex.Message object  in getFunds() it shows me an error saying return type does not match

 

Thanks in advance!!

Hi all, I'm trying to delpoy the Round Robin Assigmnet app that I've tailored to work with leads.

 

Unfortunatly, the test class is failing 1 out of 4 and this means I can't deploy to my production, can you guys help?

 

Here's the whole test class and I've highlighted the line referenced in the error (Class.TestMethodClsLeads1.myTest3: line 217, column 1) in bold. Any ideas?

 

@isTest
private class TestMethodClsLeads1 {

    static testMethod void myTest1() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);

       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       // Second Queue       
       Group testGroup2 = new Group ();
       testGroup2.Name = 'TestQueue2';
       testGroup2.Type = 'Queue';
       insert testGroup2;
       
       QueueSObject testQueue2 = new QueueSObject();
       testQueue2.QueueId = testGroup2.id;
       testQueue2.SObjectType = 'Lead';
       insert testQueue2;


       test.starttest();
        
        //Run test

        //Assign Lead with out any Assignment Groups
        Lead c1 = new Lead (Firstname='testLead', Lastname='testLead', Company='test', Phone='5555555555', Email='test@tester.com',TempOwnerID__c=testGroup2.id, OwnerID=u1.id); //TempOwnerID__c=testGroup2.id,  
        insert c1;
        update c1;
        
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;

         
        //Add bad queue name
        Assignment_Group_Queues__c agqBad = new Assignment_Group_Queues__c(name='Bad Queue',Assignment_Group_Name__c = ag1.id );

        try {
            insert agqBad; 
        } catch (DmlException e){
             System.assert(e.getMessage().contains('CUSTOM_VALIDATION_EXCEPTION'), e.getMessage()); 
        
        } //catch

        test.stoptest();
        
    }
    
    static testMethod void myTest2() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);

       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       // Second Queue       
       Group testGroup2 = new Group ();
       testGroup2.Name = 'TestQueue2';
       testGroup2.Type = 'Queue';
       insert testGroup2;
       
       QueueSObject testQueue2 = new QueueSObject();
       testQueue2.QueueId = testGroup2.id;
       testQueue2.SObjectType = 'Lead';
       insert testQueue2;


       test.starttest();
        
        //Run test
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;        

        //Add Good Queue to Assignment Group
        Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id );
        insert agq1;
        
        
        //Add User to Assignment Groups Users
        Assignment_Groups__c agu1 = new Assignment_Groups__c (User__c = u1.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2009-01-01 21:13:24') );
        insert agu1;

        Lead c2 = new Lead (Firstname='testLead', Status='New', Lastname='testLead', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup2.id , OwnerID=testGroup.id); //Set owner ID to Queue
        insert c2;
        update c2;        

        test.stoptest();
        
    }

    static testMethod void myTest3() {

        // This code runs as the system user

        User u1;

        try{
          u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator'  LIMIT 1];
        } catch (QueryException qe){

        List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000];

        for(User u : users){
            if(u.Profile.PermissionsModifyAllData = true){
              u1 = u;
              break;
        }
        }

        }

        System.debug(u1);
        
        User u2;

        try{
          u2 = [select Id from User WHERE IsActive=True AND Profile.Name = 'AMAG Standard User'  LIMIT 1];
        } catch (QueryException qe){
//should run an error test here like above.              
        }


        System.debug(u2);
        


       //*****Create Queue 
       
       Group testGroup = new Group ();
       testGroup.Name = 'TestQueue';
       testGroup.Type = 'Queue';
       insert testGroup;
       
       QueueSObject testQueue = new QueueSObject();
       testQueue.QueueId = testGroup.id;
       testQueue.SObjectType = 'Lead';
       insert testQueue;

       test.starttest();
        
        //Run test        
        
        //Create Assignment Group
        Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead');
        insert ag1;        

        //Add Good Queue to Assignment Group
        Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id );
        insert agq1;
        
         //Add User to Assignment Groups Users
        Assignment_Groups__c agu1 = new Assignment_Groups__c (User__c = u1.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2009-01-01 21:13:24') );
        insert agu1;   

        //Add User to Assignment Groups Users
Assignment_Groups__c agu2 = new Assignment_Groups__c (User__c = u2.id, Active__c='True', Group_Name__c = ag1.id, Last_Assignment__c = datetime.valueOf('2010-01-01 21:13:24') ); insert agu2; Lead c2 = new Lead (Firstname='testLead', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', OwnerID=testGroup.id); //Set owner ID to Queue insert c2; update c2; Lead c3 = new Lead (Firstname='testLead2', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup.id , OwnerID=testGroup.id); //Set owner ID to Queue insert c3; update c3; Lead c4 = new Lead (Firstname='testLead3', Status='New', Lastname='test', Company='test', Phone='5555555555', Email='test@tester.com', TempOwnerID__c=testGroup.id , OwnerID=testGroup.id); //Set owner ID to Queue insert c4; update c4; test.stoptest(); } static testMethod void myTest4() { // This code runs as the system user User u1; try{ u1 = [select Id from User WHERE IsActive=True AND Profile.Name = 'System Administrator' LIMIT 1]; } catch (QueryException qe){ List<User> users = [SELECT Id, Profile.PermissionsModifyAllData FROM User WHERE IsActive = true LIMIT 1000]; for(User u : users){ if(u.Profile.PermissionsModifyAllData = true){ u1 = u; break; } } } System.debug(u1); //*****Create Queue Group testGroup = new Group (); testGroup.Name = 'TestQueue'; testGroup.Type = 'Queue'; insert testGroup; QueueSObject testQueue = new QueueSObject(); testQueue.QueueId = testGroup.id; testQueue.SObjectType = 'Lead'; insert testQueue; test.starttest(); //Run test //Create Assignment Group Assignment_Group_Name__c ag1 = new Assignment_Group_Name__c (Name='TestAG', Type__c = 'Lead'); insert ag1; //Add Good Queue to Assignment Group Assignment_Group_Queues__c agq1 = new Assignment_Group_Queues__c(name=testGroup.Name ,Assignment_Group_Name__c = ag1.id ); insert agq1; //Test for AG-Queues already assigned to another Assignment Group -- trying to assign a group with a name that already exists.. repeats code above. Assignment_Group_Queues__c agq2 = new Assignment_Group_Queues__c(name=testGroup.Name,Assignment_Group_Name__c = ag1.id ); try { insert agq2; } catch (DmlException e){ System.assert(e.getMessage().contains('CUSTOM_VALIDATION_EXCEPTION'), e.getMessage()); } //catch test.stoptest(); } }

 

 

Hi all,


I have one Custom object CaseType__c which has some custom fields like CaseTypeName, CaseTypeDescription etc and one look up relation of another object Specimen__c which has also some fields like SpecimenName, SpeimentType, SpecimenDescription like that. On VF page I have loaded the CaeTypeName as picklist from CaseTypeObject by ApexCode.

 

Now my requirment is on the selection of particular CaseTypeName__c, all the fields of Specimen object like SpecimentName, SpecimenType SpecimenDescription should be come. Like If CaseTypeName -ABC has Specimen BCD than on the selection of CaseType-ABC all the fields of Specimen related to BCD record should display on VF page.

 

This is code but not working ,, please please help, I have ried much but did not get anything

 

<apex:page controller="ExtentionController"

extensions="CaseTypeExtention">
    <apex:form >
          <apex:pageblock title="Hello {!$User.FirstName}!" >
              <h1>Congratulations</h1>
              This is your Accession Page !!<p/>

 <apex:pageBlockSection title="Case Information" >
                   <apex:selectList value="{!objCaseType.CaseTypeName__c }" size="1" multiselect="false">
                    <apex:actionSupport event="onchange" reRender="details" action="{!readSpecimen}"/>
                        <apex:selectOptions Value="{!CaseTypeOption }">
                        </apex:selectOptions>
                        </apex:selectList>
                 </apex:pageblocksection>
            
                  <apex:pageBlockSection title="Specimen" id="details">
                        <apex:pageBlockTable value="{!SpecimenList}" var="spec"   border="red" width="500%"  >
                            <apex:column value="{!SpecimenList.Name}" width="100%"/>
                            <apex:column value="{!SpecimenList.SpecimenType__c}" width="100%"/>
                        </apex:pageBlockTable>
                    </apex:pageblocksection> 

  </apex:pageblock>
      </apex:form>

</apex:page>


Apex Code

public class CaseTypeExtention
  {
        public CaseType__c objCaseType {get;set;}
       
        public Specimen__c SpecimenList  {get;set;}
        //public List<CaseType__c> caseList {get; set;}
       
        public CaseTypeExtention(ExtentionController controller)
         {
                objCaseType = new CaseType__c();
                SpecimenList = new Specimen__c();
               // caseList  = new List<CaseType__c>();
         }
        public List<selectOption> CaseTypeOption
        {
            get
            {
                List<selectOption> CaseTypeName =new List<selectOption>();
               
                CaseTypeName.add(new selectOption('None', 'None'));
               
                for (CaseType__c cn :[select  Name , CaseTypeName__c from CaseType__c])
               
                CaseTypeName.add(new selectOption(cn.Name, cn.CaseTypeName__c));
                return CaseTypeName;
            }
            private set;
        }
                                   
        public PageReference readSpecimen()
        {
            //caseList  = [Select  Specimen__c From CaseType__c Where name = '000002' limit 1 ];
            //string specimenId = caseList.Specimen__c;
           
            SpecimenList   = [select  name, SpecimenType__c from Specimen__c where id=:objCaseType.Specimen__c ];
            return null;
        }
 }

greetings!

 

I'm working in a trigger with the next sintax

 

if (opp.stagename=='Ganada' && mapPuntasize.get(opp.id)==0 && opp.Es_Inactiva__c!=1&& (opp.FUNCION__c<>'Costumer Care' ||opp.FUNCION__c<>'Direccion MCM') ){
opp.addError('La Oportunidad debe tener al menos una punta.');
}

 

But when i test it, i get the error message using a user with Funcion Direccion MCM

 

So what i'm trying to do is to get the message when the user Funcion is not equal to Costumer or Direccion, whats is wrong? how can i add more than one OR in the if?

 

Thank you.