• Sai harsha 7
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 9
    Replies
This is my VF page code for Rendering a PDF for custom Object as below
<apex:page controller="MyController" renderAs="pdf" applyBodyTag="false">
<head>
    <style>
    body { font-family: 'Arial Unicode MS'; }

@page{
        size: letter;
        margin:10%;
        @top-left{
        	content: "Dear,";
        	font-family: Helvetica, Arial, sans-serif;
			font-size: 12px;
		}
        @bottom-right{
        	content: "Yours Sincerely,";
        	font-family: Helvetica, Arial, sans-serif;
			font-size: 10px;
		}
   }
body {
        font-family: Helvetica, Arial, sans-serif;
		font-size: 11px;
}
    </style>
</head>
	<div align="right"><strong>Date</strong>: {!DAY(Today())} {!CASE(MONTH(Today()), 1, 'January', 2, 'February', 3, 'March', 4, 'April', 5, 'May', 6, 'June', 7, 'July', 8, 'August', 9, 'September', 10, 'October', 11, 'November', 12, 'December', 'Unknown')} {!YEAR(Today())}</div>
<center>
    <h1> Letter</h1>
    </center>
    <p>{!custom_object__C.Name__C</p>    
</apex:page>

Controller page
public class MyController {
    
    private final custom_object__c customobject;
        
        public MyController(){
            customobject = [SELECT Id, Name__c FROM custom_object__c 
                        LIMIT 1];
        }
        public custom_object__c getcustom_object__c(){
            return customobject;
        }
        public PageReference save() {
            update customobject;
            return null;
        }
    }

I got the error Unknown property 'MyController.custom_object__C' in my VF page​​

Due to this compile error, in the preview screen I got the display of only top left, bottom right, centre but no data related to "<p>{!custom_object__C.Name__C</p>" line
I have added a vf page to my login flows but whenever i am trying to login into the salesforce Account it shouldn't redirect to the User-added imagecorresponding vfpage. It throws some error i.e can't display page.

Please help me out guys from this issue. 


Thanks & regards
Srikanth
Salesforce Developer
 
How to give values to lookup fields in apex class..like to give account name in opportunity object using apex class.

public opportunity op= new opportunity();
op.account='Burlington Textiles Corp of America';

i tried even by giving id of that record..but getting error as if illegal assisgnment..could any one help me out please
In order to achieve mass update of my records I tried to execute the following script:
List<Task> taskList = [SELECT status, CalculatedWorkingHours__c FROM Task WHERE CalculatedWorkingHours__c = -1.0 AND status = 'Completed'];
        for(Task task :taskList) {
            task.CalculatedWorkingHours__c = 1.0;
        }   
        update taskList;
        System.debug('taskList ' + taskList);

in Anonymous window in my Developer Console however I received the following message: 
`System.LimitException: Too many SOQL queries: 101`

Please advise how to avoid such exception and execute my script successfully?
I am facing an issue when exporting visual force page data as excel. As it exporting whole page ......The problem was like i have vf page with title and button...so when i click the button the data in pageblock table should download. but it download  including button as well . how to avoid button on page or how to download only pageblock table data.

VF code --


<apex:page Standardcontroller="Account" extensions="accNotes" standardStylesheets="false" contentType="{!IF(isExport = true, 'application/vnd.ms-excel#contacts.xls', '')}" cache="true">
<apex:form >
 <apex:pageBlock id="pgb">
 <apex:pageBlockSection columns="8" >
 <apex:outputPanel layout="block">
 <b><apex:outputLabel style="margin" value="Notes & Attachments"></apex:outputLabel></b>

 <apex:commandButton id="button" style="margin-left:80px;" value="Export as Excel" action="{!exportToExcel}" reRender="">     /////**** This is also printing on excel page when downloaded******************///  
 </apex:commandButton>

 </apex:outputPanel>
 </apex:pageBlockSection>
 
 <apex:pageBlockSection >
 <apex:pageBlockTable value="{!Recordsall}"  var="n"> 
 <apex:column style="overflow:hidden;white-space:nowrap" value="{!acc.AccountNumber}">
 <apex:facet name="header">Account Number</apex:facet>
 </apex:column>
 <apex:column style="overflow:hidden;white-space:nowrap" value="{!acc.name}">
 <apex:facet name="header">Account Name</apex:facet>
 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
 </apex:page>
issue:
While creating a New Opportunity, if user is pressing the “Enter” key, then the record is not getting save. Afer clicked on ENTER its redirecting to the opportunity list view page.
My expectation:
After all data entry in the new opportunity VF page if user click on ENTER button then the data should save and details page should open.
What is the issue on the VF page? Why ENTER button not working?

 
public class Apex_Account_search01 {
    
    
    public list<Account>  acclist   {set;get;}
    public string selected   {set;get;}
    public Apex_Account_search01(){
        
        acclist=[select id,name,phone from Account ];
    }
    
    public void sumbit(){
        
        string s=selected + '%';
        string query='select id,name,phone from Account where name like :s';
        acclist=Database.query(query);
        
    }
}
<apex:page controller="Apex_Account_search01">
<apex:form >
        <apex:inputText value="{!selected}">
            <apex:commandButton action="{!sumbit}" value="sumbit"/>
        </apex:inputText>
        <apex:pageBlock >
            
            <apex:pageBlockTable value="{!acclist}" var="a">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.phone}"/>
                <apex:column value="{!a.id}"/>       
            </apex:pageBlockTable>
        </apex:pageBlock> 
        
    </apex:form>
</apex:page>

My requirmentis that I want to make a page just like Account listView whenever i click on A all the records start with A...and B,C....and all like that
This is my VF page code for Rendering a PDF for custom Object as below
<apex:page controller="MyController" renderAs="pdf" applyBodyTag="false">
<head>
    <style>
    body { font-family: 'Arial Unicode MS'; }

@page{
        size: letter;
        margin:10%;
        @top-left{
        	content: "Dear,";
        	font-family: Helvetica, Arial, sans-serif;
			font-size: 12px;
		}
        @bottom-right{
        	content: "Yours Sincerely,";
        	font-family: Helvetica, Arial, sans-serif;
			font-size: 10px;
		}
   }
body {
        font-family: Helvetica, Arial, sans-serif;
		font-size: 11px;
}
    </style>
</head>
	<div align="right"><strong>Date</strong>: {!DAY(Today())} {!CASE(MONTH(Today()), 1, 'January', 2, 'February', 3, 'March', 4, 'April', 5, 'May', 6, 'June', 7, 'July', 8, 'August', 9, 'September', 10, 'October', 11, 'November', 12, 'December', 'Unknown')} {!YEAR(Today())}</div>
<center>
    <h1> Letter</h1>
    </center>
    <p>{!custom_object__C.Name__C</p>    
</apex:page>

Controller page
public class MyController {
    
    private final custom_object__c customobject;
        
        public MyController(){
            customobject = [SELECT Id, Name__c FROM custom_object__c 
                        LIMIT 1];
        }
        public custom_object__c getcustom_object__c(){
            return customobject;
        }
        public PageReference save() {
            update customobject;
            return null;
        }
    }

I got the error Unknown property 'MyController.custom_object__C' in my VF page​​

Due to this compile error, in the preview screen I got the display of only top left, bottom right, centre but no data related to "<p>{!custom_object__C.Name__C</p>" line
I have added a vf page to my login flows but whenever i am trying to login into the salesforce Account it shouldn't redirect to the User-added imagecorresponding vfpage. It throws some error i.e can't display page.

Please help me out guys from this issue. 


Thanks & regards
Srikanth
Salesforce Developer
 

Hi ,

I am trying to learn writing apex triggers. I tried to updte the annual revenue field with 100000, if the account name is abs., but i am unable to succeed in writing this code. Can anyone suggest me or correct me.

 

trigger test1 on Account (before insert, before update) {
list<account> a= new list<account>();
for(account acc: [select id, name from account limit 10])
{
if(acc.name=='abs')
 acc.annualrevenue='100000';
}
}

trigger test1 on Account (before insert, before update) {
list<account> a= new list<account>();
for(account acc: [select id, name from account limit 10]){if(acc.name=='abs') acc.annualrevenue='100000';
}}