• Ramesh y 10
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi All,

I need help to get the picklist values and using these values in visualforce page to hide/show the pageblock.

My requirement.
I have a object called Book in may app . Book have one field called sample1(picklist) and  it has two values..(Yes, No).

Then , I have to show entire panel based of these values( yes, or no) . Below is my code.

Apex class :
public class bookcontrol
{
public list<Book__c> allbooks {get; set;}

public list<Book__c> getBooks()
{
allbooks= [select sample1__c from Book__c where sample2 = :object2.field2 limit 1 ];
return allbooks;
}
}
(there is some logic behind the above SOQL query, it is checking another condition)


Here my question is above returened " allbooks" have my field picklist values are not?

can i use above variable in visualforce page.

My visualforce page is :
.........
......
<apex:panelGroup rendered = "{! IF(allbooks.sample1__c == 'Yes' , true, false)">
........
.......
</apex:panelGroup>

Will that above code wii work?

How to get those picklist values to my visualforce page to compare the logic. I need to show that entire panel if my field value is Yes.

Appreciate your help. 

Thanks
R
Hello, i have a simple trigger:


trigger TriggerA on Account (before insert) {
    for(Account a : Trigger.new){
      if(a.Description == NULL)
         a.addError('You must add a value');
    }
}

Error: Compile Error: Variable does not exist: Description at line 3 column 12. I don't understand why.
Hi, 

I have two objects employee__c and department__c where employee__c is the child object for department__c. My requirement is if a child record is added then the description__c field in master record should get updated. Below  is my code but it is showing Error: Compile Error: IN operator must be used with an iterable expression at line 3 column 36. Any help is appreciated.
 
trigger descriptionupdate on Employee__c (after insert) {
map<id, employee__c> myid = new map<id, employee__C>([select id, department__r.id from employee__c where id in:trigger.new]);
list<department__c> depstoupdate = [select name, description__c from department__C where id in:myid];
for(department__c d : depstoupdate){
d.description__c = 'The last employee added to this department is on ' +system.today();
}
update depstoupdate;
}

 
I am getting error  in test class as 
System.DmlException: Update failed. First exception on row 0 with id a1h17000003NcsjAAC; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please select only one checkbox: []
Class.TestselectOneCheckbox.myUnitTest: line 18, column 1
Please help :



Trigger:
trigger selectOneCheckbox on Survey_Mcd__c (before update) {
for(Survey_Mcd__c sms : Trigger.New){
  if(Trigger.isUpdate){
  if((sms.Yes_No__c && sms.X5_Scale_Rating__c && sms.Comment__c)  || (sms.Yes_No__c && sms.X5_Scale_Rating__c)  
  || (sms.Yes_No__c && sms.Comment__c) || (sms.X5_Scale_Rating__c && sms.Comment__c)){
  sms.addError('Please select only one checkbox');
   }
  }
 }
}

Test class

@isTest
public class TestselectOneCheckbox {
    static testMethod  void myUnitTest() {
        system.test.startTest();
         
            Survey_Mcd__c sms= new Survey_Mcd__c();
                 sms.Yes_No__c=true;
            sms.X5_Scale_Rating__c=true;
            sms.Comment__c=true;
               insert sms;
        List <Survey_Mcd__c> sm= [select id,Comment__c,X5_Scale_Rating__c,Yes_No__c 
                                  from Survey_Mcd__c where id=:sms.id];
         for ( Survey_Mcd__c v:sm)
        {
            v.Comment__c=true;
            v.X5_Scale_Rating__c=false;
        } 
    update sm;
        Survey_Mcd__c sms1= new Survey_Mcd__c();
                 sms1.Yes_No__c=true;
            sms1.X5_Scale_Rating__c=true;
            sms1.Comment__c=true;
               update sms1;
            system.test.stopTest();
        }
}