• Navneeth Raj
  • NEWBIE
  • 65 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 21
    Replies
User-added image
Scenario when user enter numbers other than ten digits error should arise.
But above error oscurs
(use this validation WITHOUT REGEX function)
SCENARIO: If Lead Status is "Open - Not Contacted" add to Account else if it is "Working - Contacted" add to Opportunity
trigger AutoQualifyLead2 on Lead (after insert) {
    List<Account> accs=new List<Account> ();
    List<Opportunity> opps=new List<Opportunity> ();
    for(Lead l:Trigger.New)
    {
        if(l.Status=='Open - Not Contacted'){
            Account a=new Account();
            a.Fax=l.Fax;
            a.Phone=l.Phone;
            a.Industry=l.Industry;
            accs.add(a);
        }
        else{
            if(l.Status=='Working - Contacted'){
                Opportunity op=new Opportunity();
                op.Name=l.Name;
                op.Description=l.Description;
                opps.add(op);
            }
        }
    }
    if(accs.size()>0){    insert accs;    }
    if(opps.size()>0){    insert opps;    }
}
ERROR: As seen in attached Image
User-added image
public class SchemaExample1 {
    public Map<String,Schema.SObjectType> objMap {get;set;}
    public List<SelectOption> objs {set;get;}
    
    public SchemaExample1(){
        objMap=Schema.getGlobalDescribe();
        Set<String> key=objMap.keySet();
        
        objs=new List<SelectOption>();
        for(String s:keys){
            Schema.SObjectType sobj=oldMap.get(s);
            Schema.DescribeSObjectResult res=Sobj.getDescribe();
            SelectOption op=new selectOption(s,s);
            objs.add(op);
        }
    }
}User-added image
public class SchemaExample {
    public String result {get;set;}
        
    public SchemaExample(){
5        Schema.DescribeSObjectResult rst=Account.SObjectType.getDescribe();
        result='The obtained Result is:'+rst;
    }
}
Error:Invalid type: Schema.DescribeSObjectResult @ LINE 5
trigger instantTrigger on Opportunity (before insert,after update) {
    List<OpportunityShare> share=new List<OpportunityShare>();
    User u=[SELECT id FROM User WHERE alias='sara'];
    for(Opportunity op:Trigger.New){
        if(op.Type=='New Customer'){
            OpportunityShare so=new OpportunityShare();
            so.OpportunityId=op.id;
            so.OpportunityAccessLevel='Edit';
            so.UserOrGroupId=u.Id;
            so.RowCause='Manual';
            share.add(so);
        }
    }
    insert share;
}

Error:Apex trigger instantTrigger caused an unexpected exception, contact your administrator: instantTrigger: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []: Trigger.instantTrigger: line 14, column 1
 
Example
User-added image
APEXClass

public class CustomSettingsExample {
    public String city {get;set;}
    public String state {set;get;}
    public String code {get;set;}
    
    public void getData(){
        zipcodes__c zip=zipcodes__c.getValues(city);
        state=zip.state__c;
        city=zip.city__c;
        code=zip.code__c;        
    }
}
Related Vfp
<apex:page controller="CustomSettingsExample">
    <apex:form >
    <apex:pageblock title="Table" id="ONE">
        <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="city"/>
                <apex:inputText value="{!city}">
                    <apex:actionSupport event="onchange" action="{!getData}"  reRender="ONE"/>
                </apex:inputText>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="state"/>
                <apex:inputText value="{!state}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel value="code"/>
                <apex:inputText value="{!code}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        </apex:pageblock>
            </apex:form>
</apex:page>

ERROR
User-added image
Apex Class
public class SOQLExample {
    public String type {get;set;}
    public List<Account> accs {set;get;}
    public void getResult(){
        accs=[SELECT id,name FROM Account WHERE Type=:type];
    }
}
Vfp
<apex:page controller="SOQLExample">
    <apex:form >
        <apex:pageBlock title="soql example">
            <apex:outputText value="Enter Type:"/>  
                <apex:inputText value="{!Type}"/>
                <apex:commandButton value="Submit" action="{!getResult}"/>
        </apex:pageBlock>
        <apex:pageBlock title="Result" rendered="{! !ISNULL(accs)}">
            <apex:pageBlockTable value="{!accs}" var="account">
                <apex:column value="{!account.name}"/>
                <apex:column value="{!account.type}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
            </apex:form>
</apex:page>
What could be the error
Illegal assignment from List<System.SelectOption> to Set<String>  
@Line 15

public class FieldDependencyPickList {
public    Map<String,List<String>> cityMap{get;set;}
    public List<SelectOption> place {set;get;}
    public List<SelectOption> city {set;get;}
    public String selCity    {get;set;}
    public String selPlace    {set;get;}

public FieldDependencyPickList(){
    cityMap=new Map<String,List<String>>();
    List<String> hcityPlaces=new List<String> {'apet','npet','bpet','abpet'};
        List<String> apcityPlaces=new List<String> {'rjy','kkd','tni','vskp'};
            cityMap.put('HYD',hcityPlaces);            
            cityMap.put('AP',apcityPlaces);
                Set<String> place=cityMap.keySet();
L15   place=new List<SelectOption>();
        city=new List<SelectOption>();
        SelectOption so=new SelectOption('none','-None-');
        city.add(so);
        place.add(so);
    for(String p:place){
        SelectOption nsp=new SelectOption(p,p);
        city.add(nsp);
}  
    }
        public void placesGetter(){    
            place.clear();
            List<String> sp=cityMap.get(selcity);
            for(String pp:sp){
                SelectOption so1=new SelectOption(pp,pp);
                place.add(so1);
    }
  }
}
Apex Class
public class MultiselectExample {
    public Set<String> nscities         {Set;get;}
    public Set<String> scities          {set;get;}
    public List<SelectOption> soptions  {set;get;}
    public List<SelectOption> nsoptions   {set;get;}
    public List<String> selected        {set;get;}
    public List<String> removed     {set;get;}
      public MultiselectExample(){
        nscities=new Set<String>{'Hyd','Ban','Pune','Che'};
        scities=new Set<String>();
        soptions=new List<SelectOption>();
        nsoptions=new List<SelectOption>();
        selected=new List<String>();
        removed=new List<String>();
        calloptions();
    }
    public void callOptions(){
        nsoptions.clear();
        soptions.clear();
        if(scities.size()<=0){
            SelectOption p=new SelectOption('none','-None-');
            soptions.add(p);
        }else{
            for(String s1:scities){
                SelectOption op1=new SelectOption(s1,s1);
                soptions.add(op1);
            }
        }
         if(nscities.size()<=0){
            SelectOption p1=new SelectOption('none','-None-');
            nsoptions.add(p1);
        }else{
            for(String s2:nscities){
                SelectOption op2=new SelectOption(s2,s2);
                nsoptions.add(op2);
            }
        }
    }
    public void addElements(){
        nscities.removeAll(selected);
        scities.addAll(selected);
        calloptions();
    }
    public void removeElements(){
       scities.removeAll(removed);
       nscities.addAll(removed);
        calloptions();
    }
}


VIsualForce
<apex:page controller="MultiselectExample">
    <style>
        .mylist{
            width:100px;
            height:80px;
        }
    </style>
    <apex:form >
        <apex:pageBlock title="MultiSelect Example" >
            <apex:panelGrid columns="3" id="one">
                <apex:selectList multiselect="true" value="{!selected}" styleclass="mylist">
                    <apex:selectOptions value="{!nsoptions}" />
                </apex:selectList>
                <apex:panelGrid columns="1">
                    <apex:commandButton value="Add" action="{!addElements}" reRender="one" />    <br/>
                    <apex:commandButton value="Del" action="{!removeElements}" reRender="one" />
                </apex:panelGrid>
                <apex:selectList multiselect="true" value="{!removed}" styleclass="mylist">
                    <apex:selectOptions value="{!soptions}" />
                </apex:selectList>   
            </apex:panelGrid>
        </apex:pageBlock>
    </apex:form>
</apex:page>


The output for this is as below

User-added image
But if i selected none at right & click delete then it is added to the left as below.
User-added image
So how to write rewrite code so that when i select none at the right & delete it, then it should not add to the left (i.e to the non-selected options)
System.NullPointerException: Attempt to de-reference a null object Class.CourseWrapperList.<init>: line 10, column 1
SCENARIO: Create List of PickList options based on the courses available in the list?

And My Code for this is as below

CourseWrapper.apxc

public class CourseWrapper {
    public String cname {set;get;}
    public String ccode {get;set;}
    public CourseWrapper(String cname,String ccode)
    {
        this.cname=cname;
        this.ccode=ccode;
    }
}

CourseWrapperList.apxc
public class CourseWrapperList {
    public List<SelectOption> selected {set;get;}
    public List<CourseWrapper> courses {get;set;}
    CourseWrapper c1=new CourseWrapper('None','n');
    CourseWrapper c2=new CourseWrapper('Java','j-01');
    CourseWrapper c3=new CourseWrapper('Sfdc','sf-01');
    CourseWrapper c4=new CourseWrapper('Oracle','o-01');
    CourseWrapper c5=new CourseWrapper('Dotnet','dn-01');
    public CourseWrapperList(){
    courses.add(c1);
    courses.add(c2);
    courses.add(c3);
    courses.add(c4);
    courses.add(c5);
        so();
       }
    public pageReference so(){
    List<SelectOption> options=new List <SelectOption>();
        for(CourseWrapper c:courses){
        SelectOption op=new SelectOption(c.cname,c.ccode);
        options.add(op);
    }
          return null;
  }
}

CourseWrapperVfp.vfp
<apex:page controller="CourseWrapperList">
    <apex:form>
        <apex:pageBlock title="Courses">
            <apex:selectList value="{!selected}">
                <apex:selectOptions value="{!courses}"/>
            </apex:selectList>
        </apex:pageBlock>
        {!selected}
    </apex:form>
</apex:page>

But following (Image) Visualforce page error occurs. What is the error, How & why it occurs & how to overcome it?

User-added image
User-added image
When Execute is clicked error comes as below

Line: 1, Column: 17
Constructor not defined: [ConsWithPara].<Constructor>()
What is the usage of var name in script, i mean like below?

<apex:page controller="RemoteExample" id="page">
    <script>
        var name;
    </script>
</apex:page>
 
How to know the API names of fields of a Standard Objects like Accounts, Contacts etc & what's the navigation to view the API names of fields of standard objects
User-added image
How to bind Account Name in Accounts?
<apex:page controller="Person">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person.Person_Name}"/>
            <apex:inputField value="{!Person.Course}"/>
            <apex:inputField value="{!Student.Country}"/>     

</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
User-added image
What's wrong in the above program (ERROR in Line 0 --> Unknown property 'Person.Person') & i'm trying to get the fields of a custom obj named "Person" as shown in the above picture. How to write a class with set & get
<apex:page controller="Person">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person.Person_Name}"/>
            <apex:inputField value="{!Person.Course}"/>
            <apex:inputField value="{!Student.Country}"/>     

</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
            User-added image
What's wrong in the above program (ERROR in Line 0 --> Unknown property 'Person.Person') & i'm trying to get the fields of a custom obj named "Person" as shown in the above picture. How to write a class with set & get.
How to write a formula for an Invoice field, so that IF YOU SELECT INVOICE STATUS AS OPEN & SAVED IT THEN IT HAS TO BE SAVED AS SAY For Example  "INV-{0001} OPEN". So, that if you select Invoice from lookup from line item you come to know the status of it whether it is OPEN or CLOSED or anything by viewing it.
public class StudentNew 
{
    public string name;
    public static decimal fee=10000;
    
    public void setData(string name)
    {
        this.name=name;
        fee=fee+1000;
    }
    
    public static getData(decimal fee)
    {
        fee=fee+5000;
    }
}

This generates error "Duplicate variable fee". bt if i change fee to another word in getData method it says constructor cannot have static (but it is not constructor is it). am i doing it wrong or if so correct me. Please reply
How to know the API names of fields of a Standard Objects like Accounts, Contacts etc & what's the navigation to view the API names of fields of standard objects
public class SchemaExample {
    public String result {get;set;}
        
    public SchemaExample(){
5        Schema.DescribeSObjectResult rst=Account.SObjectType.getDescribe();
        result='The obtained Result is:'+rst;
    }
}
Error:Invalid type: Schema.DescribeSObjectResult @ LINE 5
Illegal assignment from List<System.SelectOption> to Set<String>  
@Line 15

public class FieldDependencyPickList {
public    Map<String,List<String>> cityMap{get;set;}
    public List<SelectOption> place {set;get;}
    public List<SelectOption> city {set;get;}
    public String selCity    {get;set;}
    public String selPlace    {set;get;}

public FieldDependencyPickList(){
    cityMap=new Map<String,List<String>>();
    List<String> hcityPlaces=new List<String> {'apet','npet','bpet','abpet'};
        List<String> apcityPlaces=new List<String> {'rjy','kkd','tni','vskp'};
            cityMap.put('HYD',hcityPlaces);            
            cityMap.put('AP',apcityPlaces);
                Set<String> place=cityMap.keySet();
L15   place=new List<SelectOption>();
        city=new List<SelectOption>();
        SelectOption so=new SelectOption('none','-None-');
        city.add(so);
        place.add(so);
    for(String p:place){
        SelectOption nsp=new SelectOption(p,p);
        city.add(nsp);
}  
    }
        public void placesGetter(){    
            place.clear();
            List<String> sp=cityMap.get(selcity);
            for(String pp:sp){
                SelectOption so1=new SelectOption(pp,pp);
                place.add(so1);
    }
  }
}
System.NullPointerException: Attempt to de-reference a null object Class.CourseWrapperList.<init>: line 10, column 1
SCENARIO: Create List of PickList options based on the courses available in the list?

And My Code for this is as below

CourseWrapper.apxc

public class CourseWrapper {
    public String cname {set;get;}
    public String ccode {get;set;}
    public CourseWrapper(String cname,String ccode)
    {
        this.cname=cname;
        this.ccode=ccode;
    }
}

CourseWrapperList.apxc
public class CourseWrapperList {
    public List<SelectOption> selected {set;get;}
    public List<CourseWrapper> courses {get;set;}
    CourseWrapper c1=new CourseWrapper('None','n');
    CourseWrapper c2=new CourseWrapper('Java','j-01');
    CourseWrapper c3=new CourseWrapper('Sfdc','sf-01');
    CourseWrapper c4=new CourseWrapper('Oracle','o-01');
    CourseWrapper c5=new CourseWrapper('Dotnet','dn-01');
    public CourseWrapperList(){
    courses.add(c1);
    courses.add(c2);
    courses.add(c3);
    courses.add(c4);
    courses.add(c5);
        so();
       }
    public pageReference so(){
    List<SelectOption> options=new List <SelectOption>();
        for(CourseWrapper c:courses){
        SelectOption op=new SelectOption(c.cname,c.ccode);
        options.add(op);
    }
          return null;
  }
}

CourseWrapperVfp.vfp
<apex:page controller="CourseWrapperList">
    <apex:form>
        <apex:pageBlock title="Courses">
            <apex:selectList value="{!selected}">
                <apex:selectOptions value="{!courses}"/>
            </apex:selectList>
        </apex:pageBlock>
        {!selected}
    </apex:form>
</apex:page>

But following (Image) Visualforce page error occurs. What is the error, How & why it occurs & how to overcome it?

User-added image
Hi. I am new to salesforce, in fact to development itself. Do I need prior dev experience to learn salesforce or can I start learning it from scratch easily? If I can begin, can you provide a step a step guide like from where I should start etc.?
User-added image
How to bind Account Name in Accounts?
<apex:page controller="Person">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person.Person_Name}"/>
            <apex:inputField value="{!Person.Course}"/>
            <apex:inputField value="{!Student.Country}"/>     

</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
User-added image
What's wrong in the above program (ERROR in Line 0 --> Unknown property 'Person.Person') & i'm trying to get the fields of a custom obj named "Person" as shown in the above picture. How to write a class with set & get
<apex:page controller="Person">

        <apex:sectionHeader id="Own_VisualForce" title="Student Twin" subtitle="New Twin Student"
                        description="This is the VisualForce page of Student object"
                        help="/apex/MyVisualForcePage"
                        printUrl="https://c.ap2.visual.force.com/apex/Own?core.apexpages.request.devconsole=1"/>
    <apex:form >
    <apex:pageBlock id="OwnPageblock" title="Student Edit" tabStyle="Opportunity" dir="LTR" helpTitle="Any Help?"
                    helpUrl="https://ap2.salesforce.com/_ui/core/userprofile/UserProfilePage"
                    mode="inline edit" rendered="true" lang="en-IN">
   
        <apex:pageBlockButtons id="Own_pbb" title="PageBlockButtons" dir="LTR" lang="en-US" rendered="true" >
            <apex:commandButton value="Save"/>
            <apex:commandButton value="Save & New"/>
            <apex:commandButton value="cancel" />
            
        <apex:pageBlockSection collapsible="false" columns="4" rendered="true">
            <apex:inputField value="{!Person.Person_Name}"/>
            <apex:inputField value="{!Person.Course}"/>
            <apex:inputField value="{!Student.Country}"/>     

</apex:pageBlockSection>
        </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>
</apex:page>
            User-added image
What's wrong in the above program (ERROR in Line 0 --> Unknown property 'Person.Person') & i'm trying to get the fields of a custom obj named "Person" as shown in the above picture. How to write a class with set & get.
public class StudentNew 
{
    public string name;
    public static decimal fee=10000;
    
    public void setData(string name)
    {
        this.name=name;
        fee=fee+1000;
    }
    
    public static getData(decimal fee)
    {
        fee=fee+5000;
    }
}

This generates error "Duplicate variable fee". bt if i change fee to another word in getData method it says constructor cannot have static (but it is not constructor is it). am i doing it wrong or if so correct me. Please reply
Hi, there. I have a custom obj named "Student", in that i have field named "Country", so whenever a new student is created i want the country field has to be entered automatically. How can i write trigger for that?
AND(Price__c>15,Quantity__c>4)
This Validation rule accepts Price bt won't accept Quantity as shown in image attached.
Is this formula correct or suggest me formulas for making it valid.User-added image