• pallam krushnaveni 18
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
I am validating my page after validation success ans save the record and rendering to another page.
Before render i want to display save success message and i want to render to another page .
my Apex code :
public static List<GenericObject__c> GetGenericObjectByAccount(String accountIds)
    {    
        Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.GenericObject__c .fields.getMap();
        List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();

        String theQuery = GenerateFields(fldObjMapValues );

        // Finalize query string
        theQuery += ' FROM GenericObject__c WHERE Account__c in '  + accountIds ; 

    

        // Make dynamic call
        GenericObject__c[] accList = Database.query(theQuery);
        return accList;
    }
    

Test class :
 static testMethod void test_GetGenericObjectByAccount(){
    test.startTest();
    Account act=new Account();
        act.name='test';
        act.type='Industry';
        insert act;
        Opportunity opp=new opportunity();               
        opp.IsPrivate=true;
        opp.name='zensar test';
        opp.Description='description';
        opp.StageName='zen stage';
        opp.CloseDate=date.today();
        insert opp;
    GenericObject__c go=new GenericObject__c();
    go.Account__c=act.id;
    go.opportunity__c=opp.id;
    insert go;
    list<GenericObject__c > go1=[select id,name,account__c from GenericObject__c];
    //string theQuery = ' FROM GenericObject__c WHERE Account__c in '  + act.id; 
    //string query= 'Select a.Id, a.Name, a.OwnerId  from GenericObject__c a Where a.Account__C IN \''+ act.id+'\'';
    like no : 325   :DataHelper.GetGenericObjectByAccount(go.id );
    test.stopTest();
    }
Error : 
System.QueryException: expecting a colon, found 'go.id'
Stack TraceClass.DataHelper.GetGenericObjectByAccount: line 733, column 1
Class.DataHelper_test.test_GetGenericObjectByAccount: line 325, column 1

Please help me to resolve this issue 
<apex:component >
<apex:attribute description="Acc" name="Acc" type="Account" required="true"/>                   
<apex:inputField value="{!Acc.No_of_depenents__c}" styleClass="form-control" required="true" rendered="{!IF($ObjectType.Opportunity.Fields.Interested_in__c=='Home Purchase Plan Premier', false,true)}" /> />
</apex:component >  
I am not getting any error but not hiding the field.
Please suggest me on the same  
my Apex code :
public static List<GenericObject__c> GetGenericObjectByAccount(String accountIds)
    {    
        Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.GenericObject__c .fields.getMap();
        List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();

        String theQuery = GenerateFields(fldObjMapValues );

        // Finalize query string
        theQuery += ' FROM GenericObject__c WHERE Account__c in '  + accountIds ; 

    

        // Make dynamic call
        GenericObject__c[] accList = Database.query(theQuery);
        return accList;
    }
    

Test class :
 static testMethod void test_GetGenericObjectByAccount(){
    test.startTest();
    Account act=new Account();
        act.name='test';
        act.type='Industry';
        insert act;
        Opportunity opp=new opportunity();               
        opp.IsPrivate=true;
        opp.name='zensar test';
        opp.Description='description';
        opp.StageName='zen stage';
        opp.CloseDate=date.today();
        insert opp;
    GenericObject__c go=new GenericObject__c();
    go.Account__c=act.id;
    go.opportunity__c=opp.id;
    insert go;
    list<GenericObject__c > go1=[select id,name,account__c from GenericObject__c];
    //string theQuery = ' FROM GenericObject__c WHERE Account__c in '  + act.id; 
    //string query= 'Select a.Id, a.Name, a.OwnerId  from GenericObject__c a Where a.Account__C IN \''+ act.id+'\'';
    like no : 325   :DataHelper.GetGenericObjectByAccount(go.id );
    test.stopTest();
    }
Error : 
System.QueryException: expecting a colon, found 'go.id'
Stack TraceClass.DataHelper.GetGenericObjectByAccount: line 733, column 1
Class.DataHelper_test.test_GetGenericObjectByAccount: line 325, column 1

Please help me to resolve this issue 
<apex:component >
<apex:attribute description="Acc" name="Acc" type="Account" required="true"/>                   
<apex:inputField value="{!Acc.No_of_depenents__c}" styleClass="form-control" required="true" rendered="{!IF($ObjectType.Opportunity.Fields.Interested_in__c=='Home Purchase Plan Premier', false,true)}" /> />
</apex:component >  
I am not getting any error but not hiding the field.
Please suggest me on the same