• prasanth puvvada 4
  • NEWBIE
  • 100 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 29
    Replies

hi i written this query then showing error. please help.

this is working well. 
list<product2> pro=[select id,name,(select id from attachments) from product2   ];


But here i want to show only products which product records has attachments.  But getting error. 
list<product2> pro=[select id,name,(select id from attachments) from product2 where id in (SELECT ParentId FROM Attachment)  ];

 
I want to display the todays date . so i created this component and insetedinto the aura:application.  at loading this page i am getting this error.

Error during init : Unable to find 'checkWeekday' on 'compound://c.MOTD1'.​
<aura:component implements="force:appHostable">
    <aura:attribute name="{!v.dayofweek}" type="string" default=""/>
    <aura:handler name="init" value="{!this}" action="{!c.callday}" />
    
    <aura:if isTrue="{!v.dayofweek == 'sunday' }" >
    <b>This is {!v.dayofweek} </b>
    </aura:if>
    
    <aura:if isTrue="{!v.dayofweek == 'monday'}" >
    <b>This is {!v.dayofweek} </b>
    </aura:if>
    
    <aura:if isTrue="{!v.dayofweek == 'tuesday' }">
    <b>This is {!.dayofweek} </b>
    </aura:if>
    
    <aura:if isTrue="{!v.dayofweek == 'weds' }" >
    <b> This is {!v.dayofweek} </b>
    </aura:if>
    
	
</aura:component>
 
({
	checkday : function(component) {
		var d= new Date();
        var weekday=new Array(7);
        weekday[0]= "sunday";
        weekday[1]="monday";
        weekday[2]="tuesday";
        weekday[3]="wednesday";
        
        var n=weekday[d.getday()];
        component.set("v.dayofweek",n);
	}
   
})

 
i am not able to understand        Map<Integer, List<Account>>  

If this is >>>>>>>>  Map<Integer, Account>   the map.put(1,name='prasanth');      map.put(2,name='kiran');    is this line is correct? 

please explaing example for Map<Integer, List<Account>>   .  Thanks in advance.

I understoond map<id, account>    and please tell  map<id,list<account>>    thanks in advance.  

error in visual page output page: -   at  url:- https://c.ap2.visual.force.com/apex/relatedlist?id=a0128000003j6D4

'loan__c' is not a valid child relationship name for entity customer 





V.F code:-  not showing any errors. 


    
    Youre looking at some related lists for {!customer__c.Customer_name_del__c}:
    
  

    

   

 
hi freinds,  my senario is in account object if we click of "new" then it will show form,  in that one,  i put  a condition called "if gender == male" then add "Mr." to the front of the name and if gender==felmale then add "Mrs." to the front of the name.    So i created gender field on page. And i wrote a before insert trigger. ( well this is working fine).  

Problem: after saving the record then, if i change the gender value then the name NAME also should update correctly. (example, if i change value from male to female then is should change as "Mrs."    please help me what to add in this code or i need to add another code for this problem.

|Before insert code:-
trigger beforetriggergender on Account (before insert) {
    for(account a:trigger.new)
    {
        if(a.gender_of_owner__c=='male')
            a.name='Mr. '+a.name;
        if(a.gender_of_owner__c=='female')
            a.name='Mrs. '+a.name;
    }

}


 
screen shot for edit page.
User-added image
hello i worte this validaton rule on standard object called  "account"   rule is  AnnualRevenue <= 50000

so i worote this beforetrigger and this is not working. please help me to write the correct trigger code.
 
trigger firsttrigger on Account (before insert) {
for(account a:trigger.new)
{
    a.AnnualRevenue > 30000;
}
}

 
First i wrote about "creating of new user"  Secoend "inserting a new record into ACCOUNT object".  

ERROR at V.F.page:- 
Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Account, original object: User: []
Error is in expression '{!insertUserWithRole}' in component <apex:commandButton> in page futureexample1: Class.futureexample1.insertUserWithRole: line 14, column 1

An unexpected error has occurred. Your development organization has been notified.



Apex:code
public class futureexample1 {
    @future

    public static void insertUserWithRole() 
    {

        Profile p = [SELECT Id FROM Profile WHERE Name='Contract Manager'];
        UserRole r = [SELECT Id FROM UserRole WHERE Name='COO'];
        // Create new user with a non-null user role ID 
        User u = new User(alias = 'ramu', email='prasanthssn@gmail.com', emailencodingkey='UTF-8', lastname='Yugandhar main',  languagelocalekey='en_US',  localesidkey='en_US', profileid = p.Id, userroleid = r.Id, timezonesidkey='America/Los_Angeles', username='saiprasanth1@gmail.com');
        insert u;
        
        account a1=new account(name='sai');
        insert a1;
    }
}

Visualforce page:-
 
<apex:page controller="futureexample1">
<apex:form>

<apex:commandbutton value="create user" action="{!insertUserWithRole}" />

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

 
i am trying to save this program and this is saying error. please some one help me to solve this error.  

Error is:-  Error: Compile Error: line breaks not allowed in string literals at line 9 column -1

 
public class myclass {
    @future
    public static void insertUserWithRole() 
    {

        Profile p = [SELECT Id FROM Profile WHERE Name='Contract Manager'];
        UserRole r = [SELECT Id FROM UserRole WHERE Name='COO'];
        // Create new user with a non-null user role ID 
        User u = new User(alias = 'ramu', email='prasanthssn@gmail.com', emailencodingkey='UTF-8', lastname='rampandu,  languagelocalekey='en_US',  localesidkey='en_US', profileid = p.Id, userroleid = r.Id, timezonesidkey='America/Los_Angeles', username='saiprasanth@gmail.com');
        insert u;
    }
}

 
hi  i have a formula field called "total balance"  this field is edited every time some corresponding other objects are created or edited. ok

i want to populate the value of this formula field to the custom field called "balance"   please somebody help to write workflow senario.  thanks in advance.

both of the fields are under same object called customer__c  
sir/mam  i am fully consufed about static variable in salesforce.  please somebody explain any simple static variable code like addition, subtraction etc...    please   and please use this example in apexclass + visualforce page.

and please tell me how to assign set,get to this in apex code.     public static integer a=10{set;get;}    this is not taking.  please help. 
I am wrting sql query for getting count,avg,sum,min,max aggregate functions at apex class. but i am getting this error.  please help.
 
Error: Compile Error: Illegal assignment from List<AggregateResult> to Integer at line 12 column 1  


public class soqlfunc
{
public integer count12{set;get;}
public integer avg{set;get;}
public integer sum{set;get;}
public integer max{set;get;}
public integer min{set;get;}

public soqlfunc()
{
count12=[select count() from transaction__c ];
avg=[select avg(amount__c) from transaction__c];
sum=[select sum(amount__c) from transaction__c   ];
max=[select max(amount__c) from transaction__c   ];
min=[select min(amount__c) from transaction__c   ];
}
}

 
i have written apex class (its working fine)  and VF page that is retriving the data from sub query, the error is coming at getting the data from subquery.  Error in VF:page is :-  

 Error: Invalid field loan__r for SObject customer__c

Visual force code:
 
<apex:page controller="solq3">
<apex:form>
<apex:pageblock>
<apex:pageblocktable title="customers and transactions" var="a" value="{!cuts}">
<apex:column value="{!a.id}" />
<apex:column value="{!a.Account_Type__c}" />
<apex:column value="{!a.City__c}" />
<apex:column value="{!a.Customer_name_del__c}" />


<apex:column>
<apex:repeat value="{!a.loan__r}" var="b">
{!b.Asset_cost__c} . {!b.Salary__c} <br/>

</apex:repeat>
</apex:column>


<!-- <apex:column value="{!a.Asset_cost__c}" />
<apex:column value="{!a.Salary__c}" /> -->


</apex:pageblocktable>
</apex:pageblock>
</apex:form>
</apex:page>

Apex code:
 
public class solq3
{
public list<customer__c> cuts{set;get;}
public list<account> accs{set;get;}


public solq3()
{
accs=[select id,name,industry,(select lastname,firstname,phone from contacts) from account];

cuts=[select id,Account_Type__c,City__c,Customer_name_del__c, (select Asset_cost__c,Salary__c,Applied_Date__c,Security__c from loans__r) from customer__c];


}
}


 
hello sir, i am trying to create a radio button in vf page and getting the values from apex page.  so i created this code using LIST concept. If i am trying to add one by one selectoption value then they are displaying IF i am trying to add all values using ADDALL(); then it is not loading.  please help.
 
last two lines of code for adding all selectoptions values to the list. not showing any error while saving, but output not coming at VF page. 

public class radio1
{
public string result{set;get;}

public List<selectoption> radios{set;get;}

public radio1()
{
radios=new list<selectoption>();

selectoption op1=new selectoption('prasanth','prasanth');
selectoption op2=new selectoption('Ramcharan','Ramcharan');
selectoption op3=new selectoption('pavan kalyan','pavan kalyan');
selectoption op4=new selectoption('balakrishna','balakrishna');
selectoption op5=new selectoption('mahesh','mahesh');

radios.add(op1);

list<selectoption> mylist=new list<selectoption>();
mylist.addall(radios);

}
}
 
VF page. 

<apex:page controller="radio1">
<apex:form >
<apex:pageblock >
  
  <apex:outputlabel value="radio buttons" /><br/>
  <apex:outputText value="radio buttons"  /><br/><br/><br/>
  
  <apex:selectRadio value="{!result}" title="hello" label="hi">
  <apex:selectoptions value="{!radios}" />  
  
  </apex:selectRadio>
  
  
  
  
</apex:pageblock>
</apex:form>  
</apex:page>

User-added image
sir, i am using list program.  This is a apex class program.  here i am getting all the colors vales at VF page. VF page and Apex page is working well.  here my doubt is how can i use this apex program without constructor.  please help. thanks in advance. 
 
public class listcolor
{
public list<string> color{set;get;}

public listcolor()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

I tried this, but it is giving error. 
 
public class listcolor
{
public list<string> color{set;get;}

mycolors();


public void mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

}
}

OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR OR 





public class listcolor
{
public list<string> color{set;get;}

public list<string>  mycolors()
{
color=new list<string>{'red','white','green'};

list<string> myval=new list<string>();
myval.addall(color);

return color;

}
}

Vf page ( for your reference):- 
 
<apex:page controller="listcolor" title="list of colors">
<apex:form>
<apex:pageblock>

<apex:pageblocktable var="a" value="{!color}">
<apex:column headervalue="colors" value="{!a}" />

</apex:pageblocktable>
</apex:pageblock>


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

 
senario:- in the textbox if i dont enter any data and click on submit then it say please enter name.  

This page is not showing any error. after executing the desired output is not coming.

<apex:page id="page">
<script>
function show()
{
var name=document.GetElementById('page:f1:p1:ip1').value;
if(name="" || name=nulll)
{
document.GetElementBy.id('page:f1:p1:op2').innerHtml='please enter your name';
}

</script>

<apex:form id="f1">
<apex:pageblock id="p1">
<apex:outputlabel value="Enter u r name" id="op1" />
<apex:inputtext id="ip1" />
<apex:commandbutton value="submit" onclick="show();" />
<apex:outputlabel id="op2" />




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

</apex:page>
hi, at output VF page, i have 2 input text fieds.  if i enter text and click on submit then the value should appear in the 2nd text box and also display at output label.  Here no error message is showing but it is not generating any output after click on submit button.    

please help.
 
<apex:page id="name">
<script>
function result()
{
var input=document.getElementById('name:fm:pb1:pbs1:pbsi1:in1').value;
document.getElementById('name:fm:pb1:pbs1:pbsi2:in2').value=input;
document.getElementById('name:fm:pb1:pbs1:out3').InnerHTML='my name'+input;

}

</script>

<apex:form id="fm">
<apex:pageblock id="pb1">
<apex:pageblocksection id="pbs1">

<apex:pageblocksectionitem id="pbsi1">
<apex:outputlabel value="enter u r name" id="out1"/>
<apex:inputtext id="in1" />
</apex:pageblocksectionitem>
<br/><br/>
<br/>
<br/>
<br/>

<apex:commandbutton value="submit onclick" id="c1" onclick="result();" />
<apex:commandbutton value="submit oncomplete" id="c2" oncomplete="result();" />
<br/>
<br/>
<br/>
<br/>
<br/>
<apex:pageblocksectionitem id="pbsi2">
<apex:outputlabel value="my name is:" id="out2" />
<apex:inputtext id="in2" />
</apex:pageblocksectionitem>
<apex:outputlabel value="written by js is: " id="out3" /> 

</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>

 
i am getting this error.  Error: Compile Error: Constructor not defined: [student].<Constructor>(String, Integer) at line 9 column 12


public class listex1
{
public list<student> result{set;get;}
public listex1()
{
result=new list<student>();
student s1=new student('sai',22);
student s2=new student('kiran',33);
student s3=new student('hari',34);
result.add(s1);
result.add(s2);
result.add(s3);
}
}
i have a simple apex program and i am trying to execute it from "developer console" i am getting this error.  " unexpected token: thisexample  at line 11"                  please help... thanks in advance

public class thisexample {
public integer age=10;
    public thisexample(integer age)
    {

        this.age=age;

System.debug('the value of age is '+age);    
}
}
thisexample t1=new thisexample(22);
t1.age;
I am wrting sql query for getting count,avg,sum,min,max aggregate functions at apex class. but i am getting this error.  please help.
 
Error: Compile Error: Illegal assignment from List<AggregateResult> to Integer at line 12 column 1  


public class soqlfunc
{
public integer count12{set;get;}
public integer avg{set;get;}
public integer sum{set;get;}
public integer max{set;get;}
public integer min{set;get;}

public soqlfunc()
{
count12=[select count() from transaction__c ];
avg=[select avg(amount__c) from transaction__c];
sum=[select sum(amount__c) from transaction__c   ];
max=[select max(amount__c) from transaction__c   ];
min=[select min(amount__c) from transaction__c   ];
}
}

 

hi i written this query then showing error. please help.

this is working well. 
list<product2> pro=[select id,name,(select id from attachments) from product2   ];


But here i want to show only products which product records has attachments.  But getting error. 
list<product2> pro=[select id,name,(select id from attachments) from product2 where id in (SELECT ParentId FROM Attachment)  ];

 

error in visual page output page: -   at  url:- https://c.ap2.visual.force.com/apex/relatedlist?id=a0128000003j6D4

'loan__c' is not a valid child relationship name for entity customer 





V.F code:-  not showing any errors. 


    
    Youre looking at some related lists for {!customer__c.Customer_name_del__c}:
    
  

    

   

 
hi freinds,  my senario is in account object if we click of "new" then it will show form,  in that one,  i put  a condition called "if gender == male" then add "Mr." to the front of the name and if gender==felmale then add "Mrs." to the front of the name.    So i created gender field on page. And i wrote a before insert trigger. ( well this is working fine).  

Problem: after saving the record then, if i change the gender value then the name NAME also should update correctly. (example, if i change value from male to female then is should change as "Mrs."    please help me what to add in this code or i need to add another code for this problem.

|Before insert code:-
trigger beforetriggergender on Account (before insert) {
    for(account a:trigger.new)
    {
        if(a.gender_of_owner__c=='male')
            a.name='Mr. '+a.name;
        if(a.gender_of_owner__c=='female')
            a.name='Mrs. '+a.name;
    }

}


 
screen shot for edit page.
User-added image
hello i worte this validaton rule on standard object called  "account"   rule is  AnnualRevenue <= 50000

so i worote this beforetrigger and this is not working. please help me to write the correct trigger code.
 
trigger firsttrigger on Account (before insert) {
for(account a:trigger.new)
{
    a.AnnualRevenue > 30000;
}
}

 
First i wrote about "creating of new user"  Secoend "inserting a new record into ACCOUNT object".  

ERROR at V.F.page:- 
Insert failed. First exception on row 0; first error: MIXED_DML_OPERATION, DML operation on setup object is not permitted after you have updated a non-setup object (or vice versa): Account, original object: User: []
Error is in expression '{!insertUserWithRole}' in component <apex:commandButton> in page futureexample1: Class.futureexample1.insertUserWithRole: line 14, column 1

An unexpected error has occurred. Your development organization has been notified.



Apex:code
public class futureexample1 {
    @future

    public static void insertUserWithRole() 
    {

        Profile p = [SELECT Id FROM Profile WHERE Name='Contract Manager'];
        UserRole r = [SELECT Id FROM UserRole WHERE Name='COO'];
        // Create new user with a non-null user role ID 
        User u = new User(alias = 'ramu', email='prasanthssn@gmail.com', emailencodingkey='UTF-8', lastname='Yugandhar main',  languagelocalekey='en_US',  localesidkey='en_US', profileid = p.Id, userroleid = r.Id, timezonesidkey='America/Los_Angeles', username='saiprasanth1@gmail.com');
        insert u;
        
        account a1=new account(name='sai');
        insert a1;
    }
}

Visualforce page:-
 
<apex:page controller="futureexample1">
<apex:form>

<apex:commandbutton value="create user" action="{!insertUserWithRole}" />

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

 
i am trying to save this program and this is saying error. please some one help me to solve this error.  

Error is:-  Error: Compile Error: line breaks not allowed in string literals at line 9 column -1

 
public class myclass {
    @future
    public static void insertUserWithRole() 
    {

        Profile p = [SELECT Id FROM Profile WHERE Name='Contract Manager'];
        UserRole r = [SELECT Id FROM UserRole WHERE Name='COO'];
        // Create new user with a non-null user role ID 
        User u = new User(alias = 'ramu', email='prasanthssn@gmail.com', emailencodingkey='UTF-8', lastname='rampandu,  languagelocalekey='en_US',  localesidkey='en_US', profileid = p.Id, userroleid = r.Id, timezonesidkey='America/Los_Angeles', username='saiprasanth@gmail.com');
        insert u;
    }
}

 
I am wrting sql query for getting count,avg,sum,min,max aggregate functions at apex class. but i am getting this error.  please help.
 
Error: Compile Error: Illegal assignment from List<AggregateResult> to Integer at line 12 column 1  


public class soqlfunc
{
public integer count12{set;get;}
public integer avg{set;get;}
public integer sum{set;get;}
public integer max{set;get;}
public integer min{set;get;}

public soqlfunc()
{
count12=[select count() from transaction__c ];
avg=[select avg(amount__c) from transaction__c];
sum=[select sum(amount__c) from transaction__c   ];
max=[select max(amount__c) from transaction__c   ];
min=[select min(amount__c) from transaction__c   ];
}
}

 
Hi All,

I have logged in as System Admin and switch to Standard User form Manager User. When I try to logout from the Standard User interface, instead of landing to  System admin setup page, I am logout from the salesforce.com.