• Mani Renus
  • NEWBIE
  • 163 Points
  • Member since 2013


  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 67
    Replies
Hi All,

Please help me to save the selected account records in custom object using wrapper class..
I am not able to map the fields.

Thanks a lot...

VF page:

<apex:page controller="AccountSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>


Controller:

public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}
I have created a vf Page..In that Account lookup is created when we select the account then it shows the all the contacts info of particular Account..How can we achieve this??
I have to create a vf page on contact.. in that Account lookup is created When i select a account it shows the all the contacts of that particular account aswell it display all the contact addresses in google map..How can we do this??
I have to write trigger on custom object...
I have to count the no. of accounts where territory (lookup)=t1 , then the count value display in my custom object...How can we do this using trigger??
Hi Team,
This is sainath,I am begginer, I am working on Wrapper class.
Requirements: I have to display account,contact,opportunity fields in pageblock table using wrapper class. i done with code in apex and visualforce page.But there is a issue with data alignment in pageblock table.find attached code below.
public class mswrapper
{
public class saiwrapper
{
public string Accname    {get;set;}
public string accnum     {get;set;}
public string confstname {get;set;}
public string conlstname {get;set;}
public double oppamount  {get;set;}
public string oppstgname {get;set;}
}

public list<saiwrapper> wrplst {get;set;}

public mswrapper()
{

wrplst = new list<saiwrapper>();
saiwrapper swrp;
for(Account Acclst : [SELECT Name,AccountNumber FROM Account WHERE Type = 'Customer - Direct' LIMIT 10] )
{
 swrp = new saiwrapper();
 swrp.Accname = Acclst.Name;
 swrp.accnum = Acclst.AccountNumber;
 wrplst.add(swrp);
}
for(Contact conlst :[SELECT FirstName,LastName FROM Contact WHERE Level__c = 'Primary' LIMIT 10])
{
 swrp = new saiwrapper();
 swrp.confstname = conlst.FirstName;
 swrp.conlstname = conlst.LastName;
 wrplst.add(swrp);
}
for(Opportunity opplst :[SELECT Amount,StageName FROM Opportunity WHERE Amount < 10000 LIMIT 10])
{
 swrp = new saiwrapper();
 swrp.oppamount = opplst.Amount;
 swrp.oppstgname = opplst.StageName;
 wrplst.add(swrp);
}
}
}

visualforce Page:
<apex:page controller="mswrapper">
<apex:pageBlock >
<apex:pageBlockTable value="{!wrplst}" var="wrvar">
<apex:column value="{!wrvar.Accname}" headerValue="Account Name" title="Account"/>
<apex:column value="{!wrvar.accnum}" headerValue="Account Number" title="Account"/>
<apex:column value="{!wrvar.confstname}" headerValue="Contact FirstName" title="Contact"/>
<apex:column value="{!wrvar.conlstname}" headerValue="Contact LastName" title="Contact"/>
<apex:column value="{!wrvar.oppamount}" headerValue="Amount" title="Opportunity"/>
<apex:column value="{!wrvar.oppstgname}" headerValue="StageName" title="Opportunity"/>
</apex:pageBlockTable>
</apex:pageBlock>  
</apex:page>

Output:
User-added image
All Data Should be in same rows(same alignment).But it is showing in different way.Any body can suggest how to overcome this issue.

Thanks&Regards
sainath
 
Hi All,

Please help me to save the selected account records in custom object using wrapper class..
I am not able to map the fields.

Thanks a lot...

VF page:

<apex:page controller="AccountSelectClassController" sidebar="false">
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");
            for(var i=0; i<inputCheckBox.length; i++){
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
 
            <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
                <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                        </apex:facet>
                        <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
                </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>


Controller:

public class AccountSelectClassController{
 
    //Our collection of the class/wrapper objects wrapAccount
    public List<wrapAccount> wrapAccountList {get; set;}
    public List<Account> selectedAccounts{get;set;}
 
    public AccountSelectClassController(){
        if(wrapAccountList == null) {
            wrapAccountList = new List<wrapAccount>();
            for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
                // As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
                wrapAccountList.add(new wrapAccount(a));
            }
        }
    }
 
    public void processSelected() {
    selectedAccounts = new List<Account>();
 
        for(wrapAccount wrapAccountObj : wrapAccountList) {
            if(wrapAccountObj.selected == true) {
                selectedAccounts.add(wrapAccountObj.acc);
            }
        }
    }
 
    // This is our wrapper/container class. In this example a wrapper class contains both the standard salesforce object Account and a Boolean value
    public class wrapAccount {
        public Account acc {get; set;}
        public Boolean selected {get; set;}
 
        public wrapAccount(Account a) {
            acc = a;
            selected = false;
        }
    }
}
Hi,

I want to add new line in the apex page message. Below I have used the code, but its not working for me.

       
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'Notice: <br/> Test Error Message'));
        return true;
I need to show the error message like this.How to achieve this. 

Notice:
Test Error Message.


Thanks,
Vijay
 
Hello,

This is my apex email body in the code.

   String body = 'Dear ' + con.firstname + ' ' + con.lastname + ',   ';
body += 'Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below.' ;
body +=  'Here’s the link  https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+ +con.lastname
 body += 'Best Regards,' ;

I want each of these lines on the new line.Currently it is displaying  in email as.

Dear Tejas Wadke, Thank you for considering us for your on-going software development needs. We sincerely value the opinion of our customers, and we would love to hear your opinion on our services which would help us improve the same.Please take a few minutes to complete the Feedback form by visiting the link given below. Here’s the link https://appfeedback-developer-edition.na30.force.com/survey/?email=tejas.wadke@aress.com&fullname=TejasWadkeBest Regards,https://www.tester.com?fullname=con.firstname+con.lastname

 
Hello,

I want to add a space between firstname and lastname.
I tried using %20 in an apex trigger but it does not accept the '%' and gives an error 'no viable character'.

https://appfeedback-developer-edition.na30.force.com/survey/?email='+con.email+'&fullname='+con.firstname+%20+con.lastname
Please help me on this.
Requirement :

In your Salesforce dev org, create a VF page where you can enter the name of a city. And on hitting "Fetch" button, it should fetch and display the current weather and 7 day forecast for that place.

Use Yahoo weather service API for getting the details.
https://developer.yahoo.com/weather/

this is the class I created

public class fetchweather{ public static HttpResponse makeGetCallout() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { // Deserializes the JSON string into collections of primitive data types. Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody()); system.debug(results ); } return null;

}

I called this fetch weather method in the visual force page with a controllers method. I am getting error

System.CalloutException: Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
Error is in expression '{!fetchdata}' in component <apex:commandButton> in page searchaccounts: Class.fetchweather.makeGetCallout: line 7, column 1
Class.searchAccounts.fetchdata: line 8, column 1

I know well that i am messed up with the end point URL.
Also I am not sure what to add in the remote site settings in the end point URL.

Can some one guide me how to do this??
I have an apex class which takes project Id from the URL of VF Page and displays all tasks assigned to it. The VF Page is opened from a custom button on Standard SFDC project object layout
(Sample URL: https://<sfdc instance>/apex/TaskPage?id=<projectId>)
I need help to write test class for this Apex Class

Apex Class
public class TaskClass{
	Id projectId;
	String errorMessage{get;set;}
	public List<Task__c>  taskList{get;set;}
	
	public TaskClass(){
		projectId = ApexPages.currentPage().getParameters().get('id');
		if(projectId!=null){
			try{
				taskList = [Select id,Name from Task__c where project__c =: projectId];
			}catch(Exception e){
				errorMessage = 'No records found';
			}
		}
		else
			errorMessage = 'Invalid URL';
	}
	//other functions
}

 
  • April 01, 2016
  • Like
  • 0
Hi All,
is it possible we can write a soql querys in test class .

Regards,
Viswa:)
I have a data set . and i want to interact between different Visual force pages by sharing this data.
Is it possible 

Thanks
abhilash
how to stop trigger firing process on data loder?
I have to create a soql query on accounts object, to get the records with same account name.
Hi, how can I view all my validation rules on one screen as opposed to having to go through each object?
Hi,
I need to show the input text field while changing the pick list value="Yes". Below is my code,
<apex:inputField value="{!comData.Price_decrease_to_preserve_business__c}">
                <apex:actionSupport event="onchange" reRender="reasonForPriceDecrease"/> 
                </apex:inputField>
                
               <apex:outputPanel id="reasonForPriceDecrease">                
                <apex:inputField value="{!comData.Reason_For_Price_Decrease__c}"  rendered="{!comData.Price_decrease_to_preserve_business__c=='Yes'}"/>
                 </apex:outputPanel>
From this code, I can see the input text field.But could not find the text field label.

How to show the input text field with label?

Thanks,
Chandra