-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
23Questions
-
22Replies
How to add dynamically one row in apex repeat
Hi,
I am adding quotelineitems to the quote.In pdf If line items are more table lines are not coming properly.Can any one help me.
Below is my code..
//Css
.tbl_main {
font-size: 13px;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
}
.tdCustom {
border-top: 1px solid #000;
border-right: 1px solid #000;
text-align: center;
}
.rBorder {
border-right: 1px solid #000;
}
//apex repeat table
<table cellspacing = "0" cellpadding = "0" border = "0" width = "100%" class = "tbl_main" >
<thead>
<tr >
<td width = "40px" class = "tdCustom"><b>Pos</b></td>
<td class = "tdCustom"><b>N P/N</b></td>
<td class = "tdCustom"><b>C P/N</b></td>
<td class = "tdCustom"><b>Lead Time</b></td>
<td class = "tdCustom"><b>Asked Quantity</b></td>
<td class = "tdCustom"><b>Batch Quantity</b></td>
<td class = "tdCustom"><b>Unit Price</b></td>
</tr>
</thead>
<tbody>
<apex:variable value="{!1}" var="rowNum"/>
<apex:repeat value="{!getdata }" var="q">
<tr >
<td class = "tdCustom"><apex:outputText value="{!FLOOR(rowNum)}"/></td>
<td class = "tdCustom"><apex:outputField value="{!q.Name}"/></td>
<td class = "tdCustom"><apex:outputField value="{!q.Client_P_N__c}"/></td>
<td class = "tdCustom"><apex:outputField value="{!q.Standard_Estimated_Lead_Time__c}"/></td>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<apex:repeat value="{!q.batch__r}" var="c">
<apex:panelgroup rendered="{!AND(c.Quote_Line_Item__c == q.Id,c.Id !=null)}">
<tr>
<td class = "tdCustom"><apex:outputField value="{!c.Asked_Qty__c}"/></td>
</tr>
</apex:panelgroup>
</apex:repeat>
</table>
</td>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<apex:repeat value="{!q.batch__r}" var="c">
<apex:panelgroup rendered="{!AND(c.Quote_Line_Item__c == q.Id,c.Id !=null)}">
<tr>
<td class = "tdCustom"><apex:outputField value="{!c.MOD_Maxi__c}"/></td>
</tr>
</apex:panelgroup>
</apex:repeat>
</table>
</td>
<td>
<table width="100%" cellpadding="0" cellspacing="0" border="0" >
<apex:repeat value="{!q.batch__r}" var="c">
<apex:panelgroup rendered="{!AND(c.Quote_Line_Item__c == q.Id,c.Id !=null)}">
<tr>
<td class = "tdCustom"><apex:outputField value="{!c.Unit_Price__c}"/></td>
</tr>
</apex:panelgroup>
</apex:repeat>
</table>
</td>
</tr>
<tr >
<td class = "rBorder" width="2%"></td>
<td colspan="3" class = "tdCustom" width="49%"><apex:outputField value="{!q.Description__c}"/></td>
<td colspan="3" class = "tdCustom" width="49%"><apex:outputField value="{!q.Comments__c}"/></td>
</tr>
<apex:panelGroup rendered="{!$User.Region_Text__c == 'France'}">
<tr style="page-break-inside:avoid;">
<td class = "rBorder"></td>
<td colspan="6" class = "tdCustom">
<i><center><apex:outputfield value="{!q.Quote_Validity__c}" style="padding-left:5px;"/>.</center></i>
</td>
</tr>
</apex:panelGroup>
<apex:variable var="rowNum" value="{!rowNum + 1}"/>
</apex:repeat>
</tbody>
</table>
Thanks,
-
- swapna9
- November 06, 2012
- Like
- 0
- Continue reading or reply
how to write test class for xml parsing in soap webservice class
Hi,
please can any one help me to write test class for the following class.
global class webtest
{
public Quote__c q {get;set;}
public List<Quote_Line_Item__c> lstInner { get;set; }
public static List<QlitemDetail> QlitemDetailList {get;set;}
public static String partone{get;set;}
public static String Clone{get;set;}
public webtest(ApexPages.StandardController ctlr)
{
QlitemDetailList1 = new List<QlitemDetail>();
Id = ApexPages.CurrentPage().getParameters().get('CF00NN0000000KbJB_lkid');
q =new Quote__c();
}
Public static List<QlitemDetail> Pinget() {
// some authentication code
getRes.GetInfoResult = soap.GetInfo(somedata,'somedata');
system.debug(getRes.GetInfoResult);
QlitemDetailList = new List<QlitemDetail>();
XmlStreamReader xsr = new XmlStreamReader(getRes.GetInfoResult);
while(xsr.hasNext()) {
if(xsr.getEventType()==XmlTag.START_DOCUMENT)
{
xsr.next();
xsr.next();
while(xsr.getEventType()!=XmlTag.END_DOCUMENT)
{
String partN ='';
String Clone ='';
if(xsr.getLocalName() == 'CLIENTPN')
{
xsr.next();
while(xsr.getLocalName() != 'CLIENTPN')
{
if(xsr.getLocalName() == 'CLIENTPNREF')
{
xsr.next();
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
Clone = xsr.getText();
xsr.next();
}
xsr.next();
continue;
}
xsr.next();
}
}
if(xsr.getLocalName() == 'partN')
{
xsr.next();
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
partN = xsr.getText();
partone = xsr.getText();
xsr.next();
}
}
QlitemDetail q = new QlitemDetail();
q.partN = partN;
q.partD = partD;
q.check = false;
QlitemDetailList.add(q);
xsr.next();
}
}
}
return QlitemDetailList ;
}
}
}
global class QlitemDetail {
public String partN {get;set;}
public String Clone {get;set;}
public Boolean check {get;set;}
}
}
Thanks in advance
-
- swapna9
- October 26, 2012
- Like
- 0
- Continue reading or reply
Not able to call static list from static method to non static method
Hi,
I am working on soap integration.In one method I am calling webservice method and adding all the values into one list then displayed list in visualforce page.Upto this its working fine.After this I am trying to call the same list in another method.In debug log i am getting null.
can anyone suggest me how to call static webservice method data(list) to other method.
here is the code:
global class WebserviceCall1 {
public static List<QlitemDetail> QlitemDetailList {get;set;}
public WebserviceCall1(ApexPages.StandardController controller) {
}
public WebserviceCall1() {
}
@future (callout=true)
WebService static void getPin() {
//Here Authentication code I written.
QlitemDetailList = new List<QlitemDetail>();
XmlStreamReader xsr = new XmlStreamReader(getRes.GetInfoResult);
while(xsr.hasNext()) {
if(xsr.getEventType()==XmlTag.START_DOCUMENT)
{
xsr.next();
xsr.next();
while(xsr.getEventType()!=XmlTag.END_DOCUMENT)
{
String PNumber ='';
if(xsr.getLocalName() == 'PNUMBER')
{
system.debug(xsr.getLocalName());
xsr.next();
system.debug(xsr.getEventType());
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
PNumber = xsr.getText();
xsr.next();
}
}
QlitemDetail q = new QlitemDetail();
q.Number = PNumber;
QlitemDetailList.add(q);
xsr.next();
system.debug('------------------'+QlitemDetailList);
}
}
}
}
public void Sendpin1() {
system.debug('-------Sendpin-----------'+QlitemDetailList);
//here QlitemDetailList is displaying null
}
public class QlitemDetail {
public String PNumber {get;set;}
}
}
Thanks in advance,
-
- swapna9
- October 09, 2012
- Like
- 0
- Continue reading or reply
How to generate a visual force page as popup window when we click on custom button
Hi,
I am doing one VF Page.In this one custom button is there.If I click on this button it should open another visualforce page as popup window.
How can I acheive this.Can anyone please suggest me...
Thanks in Advance,
-
- swapna9
- September 25, 2012
- Like
- 0
- Continue reading or reply
How to cover java script variables in test class
Hi All,
I am passing javascript value from vf page to controller.But I was unable to cover test class.
Here is my vf code and apex class code:
Vf Page:
function showAlert(msg){
var X = document.getElementById(msg).value;
Batch1(X);
}
<input type="Button" onclick="showAlert('{!$Component.Name}');" value="Add Batch" valign="top" /></td>
<apex:actionFunction name="Batch1" action="{!AddBatch}" reRender="pb1,errormsg" >
<apex:param id="X" name="X" value="" />
</apex:actionFunction>
Apex class:
public void AddBatch()
{
getdata =[Select id,Name,Client_P_N__c,Description__c,Standard_Estimated_Lead_Time__c,Other_Lead_Time__c,Quote__c from Quote_Line_Item__c where Quote1__c=: Id] ;
for(Quote_line_item__c q : getdata )
{
for(integer i=0;i<lstInner.size();i++)
{
if(lstInner[i].id == null)
{
if(q.name == lstInner[i].Name )
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Nicomatic P/N'+' ' +lstInner[i].Name +' '+'is already existed with the same Quote');
ApexPages.addMessage(myMsg);
return;
}
}
}
}
for(integer i=0;i<lstInner.size();i++)
{
if(lstInner[i].id == null)
{
insert lstInner[i];
}
else
if(lstInner[i].id != null)
{
update lstInner[i];
}
}
system.debug('---X value---------'+ApexPages.CurrentPage().getParameters().get('X'));
// "in the below line i am getting error as List has no rows for assignment to SObject"
Quote_Line_Item__c q = [select id,Description__c from Quote_Line_Item__c where name =: ApexPages.CurrentPage().getParameters().get('X') AND Quote1__c =: Id LIMIT 1 ];
Batch__c b = new Batch__c();
b.Quote_Line_Item__c = q.Id;
lstAcct1.add(b);
System.debug(lstAcct1);
System.debug(lstAcct1.size());
try
{
upsert lstAcct1;
}
catch(DMLException e)
{
ApexPages.Message msg = new ApexPages.Message(Apexpages.Severity.ERROR, e.getMessage() );
ApexPages.addMessage(msg);
}
innerId= new set<Id>();
for(Quote_Line_item__c q1: lstInner) {
innerId.add(q1.Id);
}
childId= new set<Id>();
for(batch__c b1: lstAcct1) {
childId.add(b1.Id);
}
}
If I call the AddBatch() in test class I am Getting error as "List has no rows for assignment to SObject"
Can any one please guide me....
Thanks in advance,
-
- swapna9
- September 17, 2012
- Like
- 0
- Continue reading or reply
Problem with task workflow
Hi,
I have a checkbox field in task "Test_Check__c".
I want to compare Remider Date/Time with now() i.e If Reminder Date/Time is equals to now() then i want to update "Test_Check__c" as true.
But I am not able to compare Remider Date/Time with now() in entri criteria.In formula criteria also "Remider Date/Time" field is not appearing.
Can anyone suggest me...
Thanks,
-
- swapna9
- July 25, 2012
- Like
- 0
- Continue reading or reply
Problem with app exchange product :Chatter Translate
Hi,
I am trying to install Chatter Translate App exchange product.
In this I need to copy apex class which is provided by app exchage.
while copying this class I am getting the follwing error:
Error: Compile Error: No such relation 'FeedPost' on entity 'UserFeed'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 25 column 24
Below is the class:
public with sharing class ChatterTranslateJsController extends BaseCustomActionJsController {
public override String actionId() {
return 'translate';
}
public override List<String> getActionHtmls(List<String> fiIds) {
Set<String> translatableFeedIds = new Set<String>();
for (UserFeed uf : [SELECT Id FROM UserFeed WHERE Type !='ContentPost' AND Id IN :fiIds LIMIT :fiIds.size()]) {
translatableFeedIds.add((uf.Id + '').substring(0,15));
}
List<String> labels = new List<String>();
for (String fiId : fiIds) {
labels.add(getActionLinkHtml(fiId, 'translate', ' ', ' - Translate'));
}
return labels;
}
public override void handleAction(String fiId, String parentId, String op, String param) {
userfeed ochat = [select id, body, InsertedById from userfeed where feedpost.feeditemid =: fiId];
user cuser = [select id,LanguageLocaleKey from user where id =: ochat.insertedbyid];
string slang = langpick.getlang(cuser.LanguageLocaleKey);
string tlang = langpick.getlang(userinfo.getlanguage());
List<CoreLanguage__c> cl = CoreLanguage__c.getall().values();
string key = cl[0].Google_API_Key__c;
string endpoint = cl[0].endpoint__c;
string desci = EncodingUtil.urlEncode(ochat.body, 'UTF-8');
string url = endpoint + '?key='+key+'&q='+ desci +'&source='+ slang +'&target='+ tlang;
translatepost.transpost(url, ochat.id,'ignoreme');
changeActionHtml(fiId, getActionLinkHtml(fiId, 'translate', '', ' - Translating...refresh page to view'));
}
}
Please can any one guide me..
Thanks in advance,
-
- swapna9
- June 26, 2012
- Like
- 0
- Continue reading or reply
Regarding Multicurrency
Hi,
I enabled multi currency in my instance.In opportunity Amount and Opportunity Currency fields are there.
what ever we select the currency type from Opportunity Currency .i wanted to change it into USD and store this value into one custom field
(Currency_Convertor__c).
Please can any one guide me....
Thanks in advance,
-
- swapna9
- June 01, 2012
- Like
- 0
- Continue reading or reply
Value is not updating properly
Hi,
I have one custom object as service request(Service_Request__C).it is having lookup to user (filed name:Service_Assistant__c).
I am updating this field value with one user name using work flow.
After creating record in service request i want to create 2 tasks. one is with the current user name and another one is with another user name which i am updating with work flow.(Service_Assistant__c).
but my trigger is creating two tasks with same owner id.task is not getting created with the other username which i am updating with work flow..
below is my code
trigger taskcreation on Service_Request__c (after insert) {
for(Service_Request__c sr:trigger.new)
{
Task t= new Task();
t.ActivityDate = sr.Due_Date__c;
t.WhatId = sr.id;
insert t;
Task t1= new Task();
t1.ActivityDate = sr.Due_Date__c;
t1.WhatId = sr.id;
if(t1.OwnerId !=null)
t1.OwnerId = sr.Service_Assistant__r.Id; //This is not working
insert t1;
}
pleaseguide me...
Thanks in advance.....
-
- swapna9
- May 25, 2012
- Like
- 0
- Continue reading or reply
Not able to see custom fields or lookup fields in lookup filters criteria
Hi,
Under Opportunities Service_Request Object is there.In Service_Request__c object Contact_name__c Is lookup to contacts.
Here i want to filter contact name by account name.In Service_Request__C ,I pulled the account name using formula field and also i updated account name using work flow.
Formula field and related to work flow field is not appearing in filter criteria.
Can any one guide me how can i filter contact name by Account name...
Thanks in Advance,
Swapn
-
- swapna9
- May 14, 2012
- Like
- 0
- Continue reading or reply
Multiple object fields search
Hi,
I was able to search one field in one object using vf page and controller.But i want to search diiferent fileds from different objects in single vf page.
In my code i can search student name ( input field) from student object.At the same time i want search account name( which is another input field).from account object.My problem is i am able to get the record in standard controller only.
Can any one guide me.....
here is my code:
<apex:page StandardController="Student__c" extensions="SearchAppointments " showHeader="false" sidebar="False">
<apex:form >
<table>
<apex:pageBlock >
<apex:outputText > <font size="2" color="blue" >Search Appointments</font></apex:outputText>
<tr>
<td><b> Name : </b>
<apex:inputField value="{!Student__c.Name}"/>
<apex:commandButton action="{!AppSearch}" value="Search Appointments"/>
</td>
</tr>
</apex:pageBlock>
</table><br></br><br></br>
<apex:pageBlock >
<apex:pageBlockSection columns="1" title="Results">
<table>
<tr align="center">
<td align="center">
<apex:pageBlockTable value="{!AppSearchData}" var="DS" title="Available Doctors" width="100%">
<apex:column value="{!DS.Name}"/>
</apex:pageBlockTable>
</td>
</tr>
</table>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex class:
Public class SearchAppointments {
public PageReference AppSearch() {
return null;
}
public Student__c AppSearch {get;set;}
public SearchAppointments (ApexPages.StandardController controller) {
AppSearch=(Student__c)controller.getRecord();
}
public List<Student__c> getAppSearchData(){
List<Student__c> listBd=[select Id,Name from Student__c where Name=:Appsearch.Name ];
return listBd;
}
}
Thanks in advance...
-
- swapna9
- April 04, 2012
- Like
- 0
- Continue reading or reply
Regording wrapper class
Hi,
I am new to wrapper classes.I wanted to know on which situations we will use wrapper classes.
I am using the following code.But if i check the check boxes its not displaying only those records.
Here is my code:
public class wrapperClassController {
//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}
//This method uses a simple SOQL query to return a List of Contacts
public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]) {
// As each contact is processed we create a new cContact object and add it to the contactList
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected() {
//We create a new list of Contacts that we be populated only with Contacts if they are selected
List<Contact> selectedContacts = new List<Contact>();
//We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
for(cContact cCon : getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
// Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Contact con : selectedContacts) {
system.debug(con);
}
return null;
}
// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
public cContact(Contact c) {
con = c;
selected = false;
}
}
}
Vf page:
<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
can any one guide me...
Thanks in advance...
-
- swapna9
- March 20, 2012
- Like
- 0
- Continue reading or reply
DownLoad Attachments from Parent record Notes & Attachments Section on Visualforce page
Hi ,
It ll be very helpfull for me if any one can give solution.Thanks in advance.
My requirement is,I want to display list of recors of custom object on Visualforce page,this is done through apex:pageblockTable.And along with this I wanted to display DownLoad link or button(on click functionality) for every record,which has to download attachments from that parent record.It has to download all the attachments from Notes & Attachments section of parent record.
Can any one help me out here pls.
Thanks,
Swapna
-
- swapna9
- March 20, 2012
- Like
- 0
- Continue reading or reply
Dynamically add and search in visualforce page
Hi,
I am doing dynamically adding rows and dynamically searching one field while adding the row in visualforce page.
Actually adding and searching working fine in different buttons.In my requirement under quote-->Quoteline item is custom object.
in quote line item i have a button New Quote.if i click on it will open one vf page with quote fileds.after entering quote fields if i click on add quotelineitems button it will add quoteline item dynamically.This ty\ime i need to check Nicomatic P/N is already there or not.
In seperate button i am using Jeff Douglas code for dynamic search.it is working fine.If add that code with my code
debug soql is showing null.it is not dispalying query.
Can any one help me...
Here is my code:
<apex:page standardController="Quote" extensions="QuoteLineNew,TestSearch">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("NicomaticPN").value
);
}
</script>
<apex:pageMessages escape="false">
</apex:pageMessages>
<apex:pageMessages id="errors" />
<apex:form id="theForm">
<apex:pageBlock title="Quote Detail" mode="read">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!savequote}"/>
<apex:commandButton immediate="true" value="Cancel" action="{!cancel}"/>
<apex:commandButton value="Add/Edit QuoteLineItems" action="{!Method1}" rerender="theForm" status="updateStatus" id="theButton" />
<apex:actionStatus startText="Opening Quote Line Items section..." id="updateStatus"></apex:actionStatus>
<!--<apex:commandButton value="Add/Edit QuoteLineItems" reRender="p1" action="{!Method1}" /> -->
<apex:actionStatus startText=" (Opening Quote Line Items Section...)" id="QuoteLineItemSection"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Quote Information">
<apex:inputField value="{!q.Name}"/>
<apex:inputField value="{!q.Title__c}"/>
<apex:inputField value="{!q.Subject__c}"/>
<apex:outputText value="{!opp.Name}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Prepared For">
<apex:inputField value="{!q.ContactId}"/>
<apex:inputField value="{!q.Contact.Email}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information">
<apex:inputField value="{!q.Payment_Terms__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:outputPanel id="p1">
<apex:outputPanel rendered="{!a}">
<apex:pageblock id="pb" >
<apex:pageBlockButtons >
<apex:commandbutton value="Add" action="{!Add}" rerender="pb1"/>
<!--<apex:commandButton immediate="true" value="Cancel" action="{!cancel1}"/>-->
<!--<apex:commandbutton value="Save" action="{!Save}"/>-->
</apex:pageBlockButtons>
<apex:pageblock id="pb1">
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="Name" value="" />
</apex:actionFunction>
<apex:repeat value="{!lstInner}" var="e1" id="therepeat">
<apex:panelGrid columns="5">
<apex:panelGrid headerClass="Name">
<apex:facet name="header">Del</apex:facet>
<apex:commandButton value="Delete" action="{!Del}" rerender="pb1">
<apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
</apex:commandButton>
</apex:panelGrid>
<apex:panelGrid title="SPD" >
<apex:facet name="header">Nicomatic P/N</apex:facet>
<apex:inputField value="{!e1.acct.Name}" required="true" id="NicomaticPN" onkeyup="doSearch();"/>
</apex:panelGrid>
<apex:panelGrid >
<apex:facet name="header">Asked Qty</apex:facet>
<apex:inputfield value="{!e1.acct.Asked_Qty__c}"/>
</apex:panelGrid>
</apex:panelgrid>
</apex:repeat>
</apex:pageBlock>
</apex:pageblock>
</apex:outputPanel>
</apex:outputPanel>
<apex:pageblock title="Similar Quote Line Items">
<apex:pageBlock >
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Qline}" var="Ql">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Nicomatic P/N" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Nicomatic P/N" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Ql.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Client P/N" rerender="results,debug">
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Ql.Client_P_N__c}"/>
</apex:column>
<apex:column >
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:pageblock>
</apex:form>
</apex:page>
apex class:
public class QuoteLineNew
{
public Opportunity opp {get; private set;}
public boolean a{get;set;}
public boolean b{get;set;}
public Quote q {get;set;}
public List<Quote_Line_Item__c>lstAcct = new List<Quote_Line_Item__c>();
public List<innerClass> lstInner{get;set;}
public String selectedRowIndex{get;set;}
public Integer count = 1;
public Quote_Line_Item__c AppSearch {get;set;}
public QuoteLineNew(ApexPages.StandardController ctlr)
{
q =new Quote();
q = (Quote)ctlr.getRecord();
opp = [Select Id, Name From Opportunity Where Id =: q.OpportunityId];
a=false;
b=false;
lstInner = new List<innerClass>();
addMore();
selectedRowIndex = '0';
}
public void Method1()
{
a=true;
}
public void Method2()
{
b=true;
}
public PageReference savequote()
{
insert q;
for(Integer j = 0;j<lstInner.size();j++)
{
lstInner[j].acct.Quote__c = q.Id;
lstAcct.add(lstInner[j].acct);
}
insert lstAcct;
PageReference pr1 = new PageReference('https://cs6.salesforce.com/'+ApexPages.CurrentPage().getParameters().get('oppid'));
pr1.setRedirect(True);
return pr1;
}
public PageReference cancel()
{
PageReference pr2 = new PageReference('https://cs6.salesforce.com/'+ApexPages.CurrentPage().getParameters().get('oppid') );
pr2.setRedirect(True);
return pr2;
}
public PageReference cancel1()
{
PageReference pr3 = new PageReference('/apex/NewQuote');
pr3.setRedirect(True);
return pr3;
}
public void Add()
{
count = count+1;
addMore();
}
public void addMore()
{
innerClass objInnerClass = new innerClass(count);
lstInner.add(objInnerClass);
}
public void Del()
{
system.debug('selected row index---->'+selectedRowIndex);
lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
count = count - 1;
}
public class innerClass
{
public String recCount{get;set;}
public Quote_Line_Item__c acct {get;set;}
public innerClass(Integer intCount)
{
recCount = String.valueOf(intCount);
acct = new Quote_Line_Item__c();
}
}
}
public with sharing class TestSearch {
public TestSearch(QuoteLineNew controller) {
}
public TestSearch(ApexPages.StandardController controller) {
}
private String soql {get;set;}
public List<Quote_Line_Item__c> Qline{get;set;}
public String sortDir {
get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; }
set;
}
public String sortField {
get { if (sortField == null) {sortField = 'Name'; } return sortField; }
set;
}
public String debugSoql {
get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
set;
}
public TestSearch () {
soql = 'select name, Quote__c,Client_P_N__c,Unit_Price__c,Asked_Qty__c from Quote_Line_Item__c where Quote__c!= null';
runQuery();
}
public void toggleSort() {
sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
runQuery();
}
public void runQuery() {
try {
Qline= Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
}
}
public PageReference runSearch() {
String Name= Apexpages.currentPage().getParameters().get('Name');
String lastName = Apexpages.currentPage().getParameters().get('Client_P_N__c');
soql = 'select Name, Quote__c,Client_P_N__c,Unit_Price__c,Asked_Qty__c from Quote_Line_Item__c where Quote__c != null';
if (!Name.equals(''))
soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
runQuery();
return null;
}
}
Thanks in advance,
-
- swapna9
- March 12, 2012
- Like
- 0
- Continue reading or reply
Dynamic Search in visualforce page
Hi,
I am trying Jeff Douglas code to search contacts dynamically in visual force.
It is not searching properly.In Debug-SOQL it is not updating query.
Can any one guide me.
here is my code:
VF page:
<apex:page controller="ContactSearchController" sidebar="false" >
<apex:form >
<apex:pageMessages id="errors" />
<apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="criteria">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("firstName").value,
document.getElementById("lastName").value,
document.getElementById("accountName").value,
);
}
</script>
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="firstName" value="" />
<apex:param name="lastName" value="" />
<apex:param name="accountName" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">First Name<br/>
<input type="text" id="firstName" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Last Name<br/>
<input type="text" id="lastName" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Account<br/>
<input type="text" id="accountName" onkeyup="doSearch();"/>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!contacts}" var="contact">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="firstName" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.firstName}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Last Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="lastName" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.lastName}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Account" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="account.name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.account.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class ContactSearchController {
// the soql without the order and limit
private String soql {get;set;}
// the collection of contacts to display
public List<Contact> contacts {get;set;}
// the current sort direction. defaults to asc
public String sortDir {
get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; }
set;
}
// the current field to sort by. defaults to last name
public String sortField {
get { if (sortField == null) {sortField = 'lastName'; } return sortField; }
set;
}
// format the soql for display on the visualforce page
public String debugSoql {
get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
set;
}
// init the controller and display some sample data when the page loads
public ContactSearchController() {
soql = 'select firstname, lastname, account.name from contact where account.name != null';
runQuery();
}
// toggles the sorting of query from asc<-->desc
public void toggleSort() {
// simply toggle the direction
sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
// run the query again
runQuery();
}
// runs the actual query
public void runQuery() {
try {
contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
}
}
// runs the search with parameters passed via Javascript
public PageReference runSearch() {
String firstName = Apexpages.currentPage().getParameters().get('firstname');
String lastName = Apexpages.currentPage().getParameters().get('lastname');
String accountName = Apexpages.currentPage().getParameters().get('accountName');
soql = 'select firstname, lastname, account.name from contact where account.name != null';
if (!firstName.equals(''))
soql += ' and firstname LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
if (!lastName.equals(''))
soql += ' and lastname LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';
if (!accountName.equals(''))
soql += ' and account.name LIKE \''+String.escapeSingleQuotes(accountName)+'%\'';
// run the query again
runQuery();
return null;
}
}
Thanks in advance:
-
- swapna9
- March 12, 2012
- Like
- 0
- Continue reading or reply
How to dispaly output filed value based on the lookup value
Hi,
I created two objects ObjectA : name(text),Number1(number),objB(lookup to ObjectB),objBprice(number).
ObjectB:Name(text),price(number).(ex records Milk:20,
Butter:50)
In my Visualforce page i am dispalying all objectA fileds and objectB fileds.Here i am dispalying ObjectA name as input field,Number1 is input field,
ObjB is lookup field.based on lookup value i need to autopopulate (ObjectB)"price" field value in ObjBprice (of ObjectA).
Can any one guide me.
Thanks in advance.......
-
- swapna9
- March 05, 2012
- Like
- 0
- Continue reading or reply
How to prepopulate opportunity name in quote visualforce page
Hi,
I have done visualforce page for satndard quote.I want to prepopulate opportunity name in this visualforce page.
Can any one give idea.
Thanks in advance
-
- swapna9
- February 24, 2012
- Like
- 0
- Continue reading or reply
How to retain input field values after saving the record in visualforce page
Hi,
I want to reatin all input,picklist and lookup field values in the visulforce page after saving the record.
Can any one guide me.
Thanks in advance
-
- swapna9
- February 23, 2012
- Like
- 0
- Continue reading or reply
Problem with raising DML exception error in visualforce page
Hi,
in certailn condition i want dispaly an error in visual force page.but it is not happening in my code.
in my visual force page i am inserting records.in one condition i dont want to insert the record just display an error while saving the record.
in my code in that condition it is not inserted record but it is not displaying error message.it is going back to decision object.
Please guide me how to display an error in visual froce page.
my code is as follows.
vf page:
<apex:page controller="AddAssignments_controller" sidebar="false">
<script type = "text/javascript">
function MutExChkList(chk)
{
var chkList = chk.parentNode.parentNode.parentNode;
var chks = chkList.getElementsByTagName("input");
for(var i=0;i<chks.length;i++)
{
if(chks[i] != chk && chk.checked)
{
chks[i].checked=false;
}
}
}
</script>
<!--<style>
.employeeError { color: green; font-weight: strong;}
</style>-->
<apex:messages />
<apex:pageBlock >
<html xmlns="http://www.w3.org/1999/xhtml">
<apex:form >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<apex:sectionHeader title="Add Assignments"/>
<table width="60%" cellspacing="3" cellpading="2">
<!-- <tr><td><table width="70%" cellpadding="1" cellspacing="3"> -->
<tr>
<td align="center"><b>Name</b></td>
<td align="center"><b>Accountable</b></td>
</tr>
<tr><td>
<table width="70%" cellpadding="1" cellspacing="3"> -->
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment1.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment1.Accountable__c}" /></td>
</tr>
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment2.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment2.Accountable__c}" /></td>
</tr>
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment3.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment3.Accountable__c}" /></td>
</tr>
</table>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</html>
</apex:pageBlock>
</apex:page>
Apex class:
public class AddAssignments_controller {
public String getGetraci() {
return null;
}
integer tttt;
public AddAssignments_controller(ApexPages.StandardSetController controller) {
}
public AddAssignments_controller(ApexPages.StandardController controller) {
}
Raci__c r = new Raci__c();
public Raci__c getraci()
{
r = [select Name,decision__c,
Id from Raci__c
where Id =:ApexPages.CurrentPage().getParameters().get('id')];
return r;
}
Public Id I = ApexPages.CurrentPage().getParameters().get('id');
public Raci__c assignment1{ get; set; }
public Raci__c assignment2{ get; set; }
public AddAssignments_controller()
{
assignment1= new Raci__c();
assignment2= new Raci__c();
}
public PageReference save() {
if((assignment1.NameofUser__c!=null))
{
try
{
if( assignment1.Decision__r.Number_of_Accountable_Members__c >= 1 )
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
//assignment1.addError('Failed');
//here i need raise an error and should display in visual force page
}
else
{
assignment1.Decision__c=I;
insert assignment1;
}
}
catch(DmlException ex){
ApexPages.addMessages(ex);
}
}
if(assignment2.NameofUser__c!=null)
{
assignment2.Decision__c=I;
insert assignment2;
}
PageReference customer = new PageReference('https://ap1.salesforce.com/'+ I);
customer.setRedirect(true);
return customer ;
}
}
Thanks in advance
-
- swapna9
- January 12, 2012
- Like
- 0
- Continue reading or reply
Too many SOQL queries: 101
Hi All,
how to keep query out side of the loop .
my code is as below..
public List<Double> getAmount()
{
List<Training_Schedule__c> Training= new List<Training_Schedule__c>();
List<Revenue_Schedule__c> revenue=new List<Revenue_Schedule__c>();
revenue=[select id,Date__c from Revenue_Schedule__c where Price_Book_Name__c=:price[0].Id];
for(Integer k=0;k<revenue.size();k++)
{
Training=[select id,Amount__c,Revenue_Date__c from Training_Schedule__c where Revenue_Schedule__c=:revenue[k].Id ];
amt=0;
for(Integer j=0;j<Training.size();j++)
{
if(Training[j].Amount__c!=null)
{
amt=amt+(Training[j].Amount__c);
}
}
Amount.add(amt);
}
return Amount;
}
Thanks...
-
- swapna9
- December 26, 2011
- Like
- 0
- Continue reading or reply
Not able to call static list from static method to non static method
Hi,
I am working on soap integration.In one method I am calling webservice method and adding all the values into one list then displayed list in visualforce page.Upto this its working fine.After this I am trying to call the same list in another method.In debug log i am getting null.
can anyone suggest me how to call static webservice method data(list) to other method.
here is the code:
global class WebserviceCall1 {
public static List<QlitemDetail> QlitemDetailList {get;set;}
public WebserviceCall1(ApexPages.StandardController controller) {
}
public WebserviceCall1() {
}
@future (callout=true)
WebService static void getPin() {
//Here Authentication code I written.
QlitemDetailList = new List<QlitemDetail>();
XmlStreamReader xsr = new XmlStreamReader(getRes.GetInfoResult);
while(xsr.hasNext()) {
if(xsr.getEventType()==XmlTag.START_DOCUMENT)
{
xsr.next();
xsr.next();
while(xsr.getEventType()!=XmlTag.END_DOCUMENT)
{
String PNumber ='';
if(xsr.getLocalName() == 'PNUMBER')
{
system.debug(xsr.getLocalName());
xsr.next();
system.debug(xsr.getEventType());
if (xsr.getEventType() == XmlTag.CHARACTERS)
{
PNumber = xsr.getText();
xsr.next();
}
}
QlitemDetail q = new QlitemDetail();
q.Number = PNumber;
QlitemDetailList.add(q);
xsr.next();
system.debug('------------------'+QlitemDetailList);
}
}
}
}
public void Sendpin1() {
system.debug('-------Sendpin-----------'+QlitemDetailList);
//here QlitemDetailList is displaying null
}
public class QlitemDetail {
public String PNumber {get;set;}
}
}
Thanks in advance,
- swapna9
- October 09, 2012
- Like
- 0
- Continue reading or reply
Problem with task workflow
Hi,
I have a checkbox field in task "Test_Check__c".
I want to compare Remider Date/Time with now() i.e If Reminder Date/Time is equals to now() then i want to update "Test_Check__c" as true.
But I am not able to compare Remider Date/Time with now() in entri criteria.In formula criteria also "Remider Date/Time" field is not appearing.
Can anyone suggest me...
Thanks,
- swapna9
- July 25, 2012
- Like
- 0
- Continue reading or reply
Value is not updating properly
Hi,
I have one custom object as service request(Service_Request__C).it is having lookup to user (filed name:Service_Assistant__c).
I am updating this field value with one user name using work flow.
After creating record in service request i want to create 2 tasks. one is with the current user name and another one is with another user name which i am updating with work flow.(Service_Assistant__c).
but my trigger is creating two tasks with same owner id.task is not getting created with the other username which i am updating with work flow..
below is my code
trigger taskcreation on Service_Request__c (after insert) {
for(Service_Request__c sr:trigger.new)
{
Task t= new Task();
t.ActivityDate = sr.Due_Date__c;
t.WhatId = sr.id;
insert t;
Task t1= new Task();
t1.ActivityDate = sr.Due_Date__c;
t1.WhatId = sr.id;
if(t1.OwnerId !=null)
t1.OwnerId = sr.Service_Assistant__r.Id; //This is not working
insert t1;
}
pleaseguide me...
Thanks in advance.....
- swapna9
- May 25, 2012
- Like
- 0
- Continue reading or reply
Not able to see custom fields or lookup fields in lookup filters criteria
Hi,
Under Opportunities Service_Request Object is there.In Service_Request__c object Contact_name__c Is lookup to contacts.
Here i want to filter contact name by account name.In Service_Request__C ,I pulled the account name using formula field and also i updated account name using work flow.
Formula field and related to work flow field is not appearing in filter criteria.
Can any one guide me how can i filter contact name by Account name...
Thanks in Advance,
Swapn
- swapna9
- May 14, 2012
- Like
- 0
- Continue reading or reply
Multiple object fields search
Hi,
I was able to search one field in one object using vf page and controller.But i want to search diiferent fileds from different objects in single vf page.
In my code i can search student name ( input field) from student object.At the same time i want search account name( which is another input field).from account object.My problem is i am able to get the record in standard controller only.
Can any one guide me.....
here is my code:
<apex:page StandardController="Student__c" extensions="SearchAppointments " showHeader="false" sidebar="False">
<apex:form >
<table>
<apex:pageBlock >
<apex:outputText > <font size="2" color="blue" >Search Appointments</font></apex:outputText>
<tr>
<td><b> Name : </b>
<apex:inputField value="{!Student__c.Name}"/>
<apex:commandButton action="{!AppSearch}" value="Search Appointments"/>
</td>
</tr>
</apex:pageBlock>
</table><br></br><br></br>
<apex:pageBlock >
<apex:pageBlockSection columns="1" title="Results">
<table>
<tr align="center">
<td align="center">
<apex:pageBlockTable value="{!AppSearchData}" var="DS" title="Available Doctors" width="100%">
<apex:column value="{!DS.Name}"/>
</apex:pageBlockTable>
</td>
</tr>
</table>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex class:
Public class SearchAppointments {
public PageReference AppSearch() {
return null;
}
public Student__c AppSearch {get;set;}
public SearchAppointments (ApexPages.StandardController controller) {
AppSearch=(Student__c)controller.getRecord();
}
public List<Student__c> getAppSearchData(){
List<Student__c> listBd=[select Id,Name from Student__c where Name=:Appsearch.Name ];
return listBd;
}
}
Thanks in advance...
- swapna9
- April 04, 2012
- Like
- 0
- Continue reading or reply
Regording wrapper class
Hi,
I am new to wrapper classes.I wanted to know on which situations we will use wrapper classes.
I am using the following code.But if i check the check boxes its not displaying only those records.
Here is my code:
public class wrapperClassController {
//Our collection of the class/wrapper objects cContact
public List<cContact> contactList {get; set;}
//This method uses a simple SOQL query to return a List of Contacts
public List<cContact> getContacts() {
if(contactList == null) {
contactList = new List<cContact>();
for(Contact c : [select Id, Name, Email, Phone from Contact limit 10]) {
// As each contact is processed we create a new cContact object and add it to the contactList
contactList.add(new cContact(c));
}
}
return contactList;
}
public PageReference processSelected() {
//We create a new list of Contacts that we be populated only with Contacts if they are selected
List<Contact> selectedContacts = new List<Contact>();
//We will cycle through our list of cContacts and will check to see if the selected property is set to true, if it is we add the Contact to the selectedContacts list
for(cContact cCon : getContacts()) {
if(cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
// Now we have our list of selected contacts and can perform any type of logic we want, sending emails, updating a field on the Contact, etc
System.debug('These are the selected Contacts...');
for(Contact con : selectedContacts) {
system.debug(con);
}
return null;
}
// This is our wrapper/container class. A container class is a class, a data structure, or an abstract data type whose instances are collections of other objects. In this example a wrapper class contains both the standard salesforce object Contact and a Boolean value
public class cContact {
public Contact con {get; set;}
public Boolean selected {get; set;}
//This is the contructor method. When we create a new cContact object we pass a Contact that is set to the con property. We also set the selected value to false
public cContact(Contact c) {
con = c;
selected = false;
}
}
}
Vf page:
<apex:page controller="wrapperClassController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Process Selected" action="{!processSelected}" rerender="table"/>
</apex:pageBlockButtons>
<!-- In our table we are displaying the cContact records -->
<apex:pageBlockTable value="{!contacts}" var="c" id="table">
<apex:column >
<!-- This is our selected Boolean property in our wrapper class -->
<apex:inputCheckbox value="{!c.selected}"/>
</apex:column>
<!-- This is how we access the contact values within our cContact container/wrapper -->
<apex:column value="{!c.con.Name}" />
<apex:column value="{!c.con.Email}" />
<apex:column value="{!c.con.Phone}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
can any one guide me...
Thanks in advance...
- swapna9
- March 20, 2012
- Like
- 0
- Continue reading or reply
Dynamic Search in visualforce page
Hi,
I am trying Jeff Douglas code to search contacts dynamically in visual force.
It is not searching properly.In Debug-SOQL it is not updating query.
Can any one guide me.
here is my code:
VF page:
<apex:page controller="ContactSearchController" sidebar="false" >
<apex:form >
<apex:pageMessages id="errors" />
<apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="criteria">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("firstName").value,
document.getElementById("lastName").value,
document.getElementById("accountName").value,
);
}
</script>
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="firstName" value="" />
<apex:param name="lastName" value="" />
<apex:param name="accountName" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">First Name<br/>
<input type="text" id="firstName" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Last Name<br/>
<input type="text" id="lastName" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Account<br/>
<input type="text" id="accountName" onkeyup="doSearch();"/>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!contacts}" var="contact">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="First Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="firstName" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.firstName}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Last Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="lastName" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.lastName}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Account" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="account.name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!contact.account.name}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public with sharing class ContactSearchController {
// the soql without the order and limit
private String soql {get;set;}
// the collection of contacts to display
public List<Contact> contacts {get;set;}
// the current sort direction. defaults to asc
public String sortDir {
get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; }
set;
}
// the current field to sort by. defaults to last name
public String sortField {
get { if (sortField == null) {sortField = 'lastName'; } return sortField; }
set;
}
// format the soql for display on the visualforce page
public String debugSoql {
get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
set;
}
// init the controller and display some sample data when the page loads
public ContactSearchController() {
soql = 'select firstname, lastname, account.name from contact where account.name != null';
runQuery();
}
// toggles the sorting of query from asc<-->desc
public void toggleSort() {
// simply toggle the direction
sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
// run the query again
runQuery();
}
// runs the actual query
public void runQuery() {
try {
contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
} catch (Exception e) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
}
}
// runs the search with parameters passed via Javascript
public PageReference runSearch() {
String firstName = Apexpages.currentPage().getParameters().get('firstname');
String lastName = Apexpages.currentPage().getParameters().get('lastname');
String accountName = Apexpages.currentPage().getParameters().get('accountName');
soql = 'select firstname, lastname, account.name from contact where account.name != null';
if (!firstName.equals(''))
soql += ' and firstname LIKE \''+String.escapeSingleQuotes(firstName)+'%\'';
if (!lastName.equals(''))
soql += ' and lastname LIKE \''+String.escapeSingleQuotes(lastName)+'%\'';
if (!accountName.equals(''))
soql += ' and account.name LIKE \''+String.escapeSingleQuotes(accountName)+'%\'';
// run the query again
runQuery();
return null;
}
}
Thanks in advance:
- swapna9
- March 12, 2012
- Like
- 0
- Continue reading or reply
How to prepopulate opportunity name in quote visualforce page
Hi,
I have done visualforce page for satndard quote.I want to prepopulate opportunity name in this visualforce page.
Can any one give idea.
Thanks in advance
- swapna9
- February 24, 2012
- Like
- 0
- Continue reading or reply
How to retain input field values after saving the record in visualforce page
Hi,
I want to reatin all input,picklist and lookup field values in the visulforce page after saving the record.
Can any one guide me.
Thanks in advance
- swapna9
- February 23, 2012
- Like
- 0
- Continue reading or reply
Problem with raising DML exception error in visualforce page
Hi,
in certailn condition i want dispaly an error in visual force page.but it is not happening in my code.
in my visual force page i am inserting records.in one condition i dont want to insert the record just display an error while saving the record.
in my code in that condition it is not inserted record but it is not displaying error message.it is going back to decision object.
Please guide me how to display an error in visual froce page.
my code is as follows.
vf page:
<apex:page controller="AddAssignments_controller" sidebar="false">
<script type = "text/javascript">
function MutExChkList(chk)
{
var chkList = chk.parentNode.parentNode.parentNode;
var chks = chkList.getElementsByTagName("input");
for(var i=0;i<chks.length;i++)
{
if(chks[i] != chk && chk.checked)
{
chks[i].checked=false;
}
}
}
</script>
<!--<style>
.employeeError { color: green; font-weight: strong;}
</style>-->
<apex:messages />
<apex:pageBlock >
<html xmlns="http://www.w3.org/1999/xhtml">
<apex:form >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<apex:sectionHeader title="Add Assignments"/>
<table width="60%" cellspacing="3" cellpading="2">
<!-- <tr><td><table width="70%" cellpadding="1" cellspacing="3"> -->
<tr>
<td align="center"><b>Name</b></td>
<td align="center"><b>Accountable</b></td>
</tr>
<tr><td>
<table width="70%" cellpadding="1" cellspacing="3"> -->
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment1.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment1.Accountable__c}" /></td>
</tr>
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment2.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment2.Accountable__c}" /></td>
</tr>
<tr>
<td align="center" width="14%"><apex:inputField value="{!assignment3.NameofUser__c}"/></td>
<td align="center" width="14%"><apex:inputField value="{!assignment3.Accountable__c}" /></td>
</tr>
</table>
<apex:commandButton value="Save" action="{!save}"/>
</apex:form>
</html>
</apex:pageBlock>
</apex:page>
Apex class:
public class AddAssignments_controller {
public String getGetraci() {
return null;
}
integer tttt;
public AddAssignments_controller(ApexPages.StandardSetController controller) {
}
public AddAssignments_controller(ApexPages.StandardController controller) {
}
Raci__c r = new Raci__c();
public Raci__c getraci()
{
r = [select Name,decision__c,
Id from Raci__c
where Id =:ApexPages.CurrentPage().getParameters().get('id')];
return r;
}
Public Id I = ApexPages.CurrentPage().getParameters().get('id');
public Raci__c assignment1{ get; set; }
public Raci__c assignment2{ get; set; }
public AddAssignments_controller()
{
assignment1= new Raci__c();
assignment2= new Raci__c();
}
public PageReference save() {
if((assignment1.NameofUser__c!=null))
{
try
{
if( assignment1.Decision__r.Number_of_Accountable_Members__c >= 1 )
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'File uploaded successfully'));
//assignment1.addError('Failed');
//here i need raise an error and should display in visual force page
}
else
{
assignment1.Decision__c=I;
insert assignment1;
}
}
catch(DmlException ex){
ApexPages.addMessages(ex);
}
}
if(assignment2.NameofUser__c!=null)
{
assignment2.Decision__c=I;
insert assignment2;
}
PageReference customer = new PageReference('https://ap1.salesforce.com/'+ I);
customer.setRedirect(true);
return customer ;
}
}
Thanks in advance
- swapna9
- January 12, 2012
- Like
- 0
- Continue reading or reply
Too many SOQL queries: 101
Hi All,
how to keep query out side of the loop .
my code is as below..
public List<Double> getAmount()
{
List<Training_Schedule__c> Training= new List<Training_Schedule__c>();
List<Revenue_Schedule__c> revenue=new List<Revenue_Schedule__c>();
revenue=[select id,Date__c from Revenue_Schedule__c where Price_Book_Name__c=:price[0].Id];
for(Integer k=0;k<revenue.size();k++)
{
Training=[select id,Amount__c,Revenue_Date__c from Training_Schedule__c where Revenue_Schedule__c=:revenue[k].Id ];
amt=0;
for(Integer j=0;j<Training.size();j++)
{
if(Training[j].Amount__c!=null)
{
amt=amt+(Training[j].Amount__c);
}
}
Amount.add(amt);
}
return Amount;
}
Thanks...
- swapna9
- December 26, 2011
- Like
- 0
- Continue reading or reply
Too many script statements: 200001
Hi,
Actually my requirement is under Price_Book__c related list is Revenue_Schedule__c ,under Revenue_Schedule__c related list is training_Schedule__c.
In Price_Book__c one button is there.once i click on that button it will open visualforce page and displays some fields from price_book__c,some fields from Revenue_Schedule__c and some fields from Training_schedule__c.In controller i am rolling up all the training schedule amount to the related revenue schedule and displaying in visual force page.First i got error as Too Many Soql Queries:101. So I kept query out side of the loop.after that amount is not rolling up properly.and again it is dispalying error as Too many script statements:200001.
Please any one give me suggestion.
My code is as follows:
public class MultipelRevenueEditFee
{
public MultipelRevenueEditFee(ApexPages.StandardController controller) {
}
List<Double> Amount=new List<Double>();
List<Double> FTES=new List<Double>();
Double fte=0;
Double amt=0;
List<Price_Book__c> price = new List<Price_Book__c>();
public List<Price_Book__c> getprice()
{
//Price_Book__c pp=[select id, opportunity_Name__r.id,FTE_Based_Services__c,Related_FTE_Service__c from Price_Book__c where id =:ApexPages.CurrentPage().getParameters().get('id')];
price =[Select Name,
Related_FTE_Service__c,
FTE_Based_Services__c,
RecordTypeID from Price_Book__c
where id =: ApexPages.CurrentPage().getParameters().get('id')];
return price;
}
List<Revenue_Schedule__c> rev = new List<Revenue_Schedule__c>();
public List<Revenue_Schedule__c> getrev()
{
rev=[Select Price_Book_Name__r.Name,
Fee_Based_Amount__c,
Name,
Date__c,
No_of_FTE__c,
Additional_Fees__c,Total_Value__c,Date_by_Plan__c,No_of_FTE_Per_Month_by_Plan__c,Gain_Share_Amount_by_Plan__c,
Fee_Based_Amount_by_Plan__c,Date_by_Forecast__c,No_of_FTE_Per_Month_by_Forecast__c,Gain_Share_Amount_by_Forecast__c,
Fee_Based_Amount_by_Forecast__c,Date_by_A_C_Mgr_Estimate__c,Fee_Based_Amount_by_A_C_Mgr__c,Gain_Share_Amount_by_A_C_Mgr_Estimate__c,
No_of_FTE_Per_Month_by_A_C_Mgr__c,Date_by_Actuals__c,Fee_Based_Amount_by_Actuals__c,Gain_Share_Amount_by_Actuals__c,
No_of_FTE_Per_Month_by_Actuals__c,Total_Value_by_A_C_Mgr_Estimates__c,Total_Value_by_Plan__c,Total_Value_by_Actuals__c,
Price_FTE_in_US__c,Total_Value_by_Forecast__c,Comments__c,No_of_FTE_s_for_Training__c
from Revenue_Schedule__c
where Price_Book_Name__c =: ApexPages.CurrentPage().getParameters().get('id') order by date__c ];
return rev;
}
public List<Double> getAmount()
{
List<Training_Schedule__c> Training= new List<Training_Schedule__c>();
List<Revenue_Schedule__c> revenue=new List<Revenue_Schedule__c>();
revenue=[select id,Date__c from Revenue_Schedule__c where Price_Book_Name__c=:price[0].Id];
set<Id> pbID = new set<Id>();
List<Revenue_Schedule__c> rsc = [select Id from Revenue_Schedule__c];
for(Revenue_Schedule__c p: rsc)
{
pbID.add(p.Id);
}
Training = [select id,Amount__c,Revenue_Date__c,Incremental_FTEs__c,No_of_FTE_for_Training__c from Training_Schedule__c where Revenue_Schedule__c IN: pbID];
for(Integer k=0;k<revenue.size();k++)
{
//Training=[select id,Amount__c,Revenue_Date__c from Training_Schedule__c where Revenue_Schedule__c=:revenue[k].Id ];
amt=0;
for(Integer j=0;j<Training.size();j++)
{
if(Training[j].Amount__c!=null)
{
amt=amt+(Training[j].Amount__c);
}
}
Amount.add(amt);
}
return Amount;
}
Public Id op;
Public PageReference return1()
{
Price_Book__c p=[select id, opportunity_Name__r.id from Price_Book__c where id =:ApexPages.CurrentPage().getParameters().get('id')];
op=p.opportunity_Name__r.id;
PageReference Opp1 = new PageReference('https://cs1.salesforce.com/'+ op);
Opp1.setRedirect(true);
UPDATE rev;
UPDATE price;
return Opp1;
}
Public Id I = ApexPages.CurrentPage().getParameters().get('id');
public PageReference save()
{
PageReference opp = new PageReference('https://cs1.salesforce.com/'+ I);
Opp.setRedirect(true);
UPDATE rev;
UPDATE price;
return Opp;
}
}
Thanks in advance..
- swapna9
- December 26, 2011
- Like
- 0
- Continue reading or reply
How do you pre-fill fields on a VisualForce page?
I have two custom objects with a parent/child relationship. Using the standard SF pages, if I click on the "New [Child Object]" button in the related list section of the Parent record the new child record page comes up with the reference field to the parent pre-filled with the parent's name.
If, however, I override the "New [Child Object]" button to point to my VisualForce page for the child the Parent's reference field is not pre-filled with the parent's name. I don't want to force my users to manually enter the parent's name as that's not consistent with standard SF pages plus it's a pain.
Is there a way to pre-fill fields on a VisualForce page in this scenario?
- CliffA
- February 14, 2009
- Like
- 0
- Continue reading or reply