• zzj8810
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
vf page:

<apex:page showHeader="false" sidebar="False" controller="textInputsCon" applyHtmlTag="true" >
    <apex:form >
      Input Text1 <apex:inputText value="{!inputText1}"/><br/>  
      <apex:selectList id="inputText3" value="{!inputText3}" size="1">
            <apex:selectOption itemValue="Name" itemLabel="Quote Number"/>
            <apex:selectOption itemValue="Quote_Line_Item__r.Quote1__r.From1__c" itemLabel="from"/>
             <apex:selectOption itemValue="Null" itemLabel="None"/>
        </apex:selectList> <br/>
            Input Text2 <apex:inputText value="{!inputText2}"/><br/>
      <apex:selectList id="inputText4" value="{!inputText4}" size="1">
            <apex:selectOption itemValue="name" itemLabel="Quote Number"/>
                 <apex:selectOption itemValue="From1__c" itemLabel="from"/>
            <apex:selectOption itemValue="From1__c" itemLabel="None"/>
        </apex:selectList>       
      <apex:selectList id="operator" value="{!operator}" size="1"><br/>
            <apex:selectOption itemValue="=" itemLabel="Equal"/>
            <apex:selectOption itemValue="!=" itemLabel="Not equal to"/>
            <apex:selectOption itemValue="<=" itemLabel="Less than"/>
        </apex:selectList>
        <apex:commandButton value="list1" action="{!showlist1}"/>
         <apex:pageBlock >
         <apex:pageBlockSection columns="1">
               <apex:pageBlockTable value="{!quo1}" var="q1">
                <apex:column value="{!q1.name}"/>
                <apex:column value="{!q1.Quote_Line_Item__c}"/>
                </apex:pageBlockTable>  
              </apex:pageBlockSection>           
        </apex:pageBlock>
    </apex:form>
    </apex:page>
controller:

public with sharing class textInputsCon {
     public String inputText1{get;set;} // input text1 value  from vf
     public String inputText2{get;set;} // input text2 value  from vf 
      public String inputText3{get;set;} // input text1 value  from vf
     public String inputText4{get;set;}
     Public string operator{get;set;}
    Public list<batch__c> quo1{get;set;}
     string query1='select name,Quote_Line_Item__c,Quote_Line_Item__r.Quote1__r.Quote_Number_New__c,Quote_Line_Item__r.Quote1__c,Quote_Line_Item__r.Quote1__r.from1__c  from  batch__c ';
     public void showlist1(){
      if(inputText1<>''){
         query1 += 'WHERE ' + inputText3 + ' ' + operator + ' : inputText1 ' ;  }
     if(inputText2<>''){
       query1 +=' and  '+ inputText4 + ' ' + operator + ' : inputText2';    }
          quo1 = database.query(query1);
     }
    }
IT IS SHOW the results when kept the data for the first time :

IT IS SHOW the results when kept the data for the first time :
User-added image

when i edit the textbox and and again click on the list1 it is showing this error :

System.QueryException: unexpected token: 'WHERE' Error is in expression '{!showlist1}' in component in page test

Class.textInputsCon.showlist1: line 19, column 1
can any body say me how to get rid of this error and .when i refreshed also it is showing the values in the textbox and same error i am getting .when i closed the window and open the same window .At the first time it is showing the results and i edit the text box and click on list it is throwing this error ?
Hey there, 

I have a very simple trigger which is designed to create a new record in the Account status object and set the name to the account name + account status. I have gotten 90% coverage, but I am not sure how to phrase the system asserts.

I tried something along the lines of: System.assertEquals('Test Account Status',Account_status__c.name);

but it wouldnt work. Below is my code, thank you ina dvance for your time.


trigger CreateAccountStatus on Account (after insert) {

List <Account_status__c> AccStatus = new List <Account_status__c> ();
    // New Account status record
   
    for (Account a : Trigger.new) {
   
   if (a.Initial_Rating_Number__c > 10) {

        Account_status__c Ast = new Account_status__c (); //instantiate the object to put values for future record
       
        // now map opportunity fields to new vehicle object that is being created with this opportunity
       
        Ast.Account__c = a.id; // and so on so forth untill you map all the fields.
        //you can also assign values
        Ast.name = a.name+' Account Status';
       
        //once done, you need to add this new object to the list that would be later inserted.
        //don't worry about the details for now
       
        AccStatus.add(Ast);
       
       
       }
       
    }//end for o
   
    //once loop is done, you need to insert new records in SF
    // dml operations might cause an error, so you need to catch it with try/catch block.
    try {
        insert AccStatus;  
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
   
}


and 

///////////////////////test\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

@istest
private class TestCreateAccountStatus {
static testMethod void CreateAccountStatus()
{
account a1=new account(name='test',Client_Branch__c='Perth',Initial_Rating_Number__c=11);
insert a1;

}
}
Good Afternoon:

I  have the following Apex Trigger and Test Class written. The Test Class passes with 100% code coverage but when I insert or update the records, the trigger is not firing. Here are both the trigger and the test class. If anyone can help explain what I've done wrong here, please let me know.

Thanks,

Matt

trigger FiopticsNotifyMeUpdate on Fioptics_Notify_Me__c (before insert, before update) {

Set<String> street = new Set<String>();
for (Fioptics_Notify_Me__c fioptics : Trigger.new) {
        street.add(fioptics.Street_Name__c);
}

Map<String, Address__c> addressMap3 = new Map<String, Address__c>();
for(Address__c address3:[Select ID, Name, House_Number__c, Parsed_Street_Name__c, Zip_Code__c, Special_Location_Value__c, Fiber_Qualified__c, IPTV_Qualified__c from Address__c where Parsed_Street_Name__c in : street])
     addressMap3.put(address3.Parsed_Street_Name__c, address3);

List<Fioptics_Notify_Me__c> notificationsToUpdate = new List <Fioptics_Notify_Me__c>();
     for(Fioptics_Notify_Me__c a : trigger.new){
          if(addressMap3.containskey(a.Street_Name__c) && addressMap3.get(a.Street_Name__c).Special_Location_Value__c == a.Apt_Floor_Unit__c && addressMap3.get(a.Street_Name__c).Zip_Code__c == a.Zip_Code__c && addressMap3.get(a.Street_Name__c).House_Number__c == a.House_Number__c && addressMap3.get(a.Street_Name__c).Fiber_Qualified__c == 'N' && addressMap3.get(a.Street_Name__c).IPTV_Qualified__c == 'N'){
                     a.Address__c = addressMap3.get(a.Street_Name__c).ID;}
         else {
          if(addressMap3.containskey(a.Street_Name__c) && addressMap3.get(a.Street_Name__c).Special_Location_Value__c == a.Apt_Floor_Unit__c && addressMap3.get(a.Street_Name__c).Zip_Code__c == a.Zip_Code__c && addressMap3.get(a.Street_Name__c).House_Number__c == a.House_Number__c && (addressMap3.get(a.Street_Name__c).Fiber_Qualified__c == 'Y' || addressMap3.get(a.Street_Name__c).IPTV_Qualified__c == 'Y')){
                     a.Address__c = addressMap3.get(a.Street_Name__c).ID;
                     a.Fioptics_Qualified__c = TRUE;}
                     }
update notificationsToUpdate;
         }
         }

@IsTest
private class FiopticsNotifyMeUpdateTestClass {
    static testMethod void validateFiopticsNotifyMeUpdate() {

          Address__c a = new Address__c (Name = '123 Main Street 45202', House_Number__c='123', Parsed_Street_Name__c='Main St', Zip_Code__c='45202');
          insert a;

          Fioptics_Notify_Me__c b = new Fioptics_Notify_Me__c (Name = 'Matt Hampton', House_Number__c = '123', Street_Name__c='Main St', Zip_Code__c='45202');
          insert b;

          Fioptics_Notify_Me__c b2 = [Select Name, Address__c, Fioptics_Qualified__c from Fioptics_Notify_Me__c where Address__c = :a.ID];

          system.assertequals(b2.Address__c, a.ID);          
         
          Address__c c = new Address__c (Name = '456 Main Street 45202', House_Number__c='456', Parsed_Street_Name__c='Main St', Zip_Code__c='45202', HSIA_Qualification__c='G');
          insert c;

          Fioptics_Notify_Me__c d = new Fioptics_Notify_Me__c (Name = 'Matt Hampton', House_Number__c = '456', Street_Name__c='Main St', Zip_Code__c='45202');
          insert d;

          Fioptics_Notify_Me__c d2 = [Select Name, Address__c, Fioptics_Qualified__c from Fioptics_Notify_Me__c where Address__c = :c.ID];

          system.assertequals(d2.Fioptics_Qualified__c, TRUE); 
          system.assertequals(d2.Address__c, c.ID);                    
    }
}

Today we’re excited to announce the new Salesforce Developers Discussion Forums. We’ve listened to your feedback on how we can improve the forums.  With Chatter Answers, built on the Salesforce1 Platform, we were able to implement an entirely new experience, integrated with the rest of the Salesforce Developers site.  By the way, it’s also mobile-friendly.

We’ve migrated all the existing data, including user accounts. You can use the same Salesforce account you’ve always used to login right away.  You’ll also have a great new user profile page that will highlight your community activity.  Kudos have been replaced by “liking” a post instead and you’ll now be able to filter solved vs unsolved posts.

This is, of course, only the beginning  and because it’s built on the Salesforce1 Platform, we’re going to be able to bring you more features faster than ever before.  Be sure to share any feedback, ideas, or questions you have on this forum post.

Hats off to our development team who has been working tirelessly over the past few months to bring this new experience to our community. And thanks to each of you for helping to build one of the most vibrant and collaborative developer communities ever.