• sunil_kumar
  • NEWBIE
  • 75 Points
  • Member since 2010
  • Salesforce Senior Developer
  • Independent Software Professional

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 35
    Replies

Hi 

In visualforce page, i am displaying the Number(16,2) fields of salary, wages etc. currently its displaying like this 10,000.00

i need it without comma for i am adding these values dynamically and save on gross pay number field. during addition it takes first two digits of before comma, it takes 10,000.00 as 10. Is there any idea to solve this issue.

 

thank you.

I have an issue with a trigger that grabs a date/time value from one field (Field 1)and populates it in another (Field 2). The issue I run into is that if Field 1 is empty I get an error which I am guessing is cause you can insert a null value in a time/date field. Is there a to leave the field blank?

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger Previous_Notes caused an unexpected exception, contact your administrator: Previous_Notes: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Previous_Notes: line 27, column 1

 

trigger Previous_Notes on Event (before insert) {
    

Set<ID> trEvent = New Set<ID>();
Map<ID, Event> mAccEvent = New Map<ID, Event>();

//Get list of WhatIDs in trigger
for(Event e : trigger.new)
    trEvent.add(e.whatID);

List<Event> lEvent = [SELECT id, Event.WhatID,Event.Previous_Completed_Date_Time__c,Event.Completed_Date_Time_-c,Event.Previous_Notes__c,Event.Relevant_Notes__c FROM Event WHERE (whatID IN :trEvent) and (Subject = 'Outside Sales Call') and  (Sales_Call_Completed__c ='Yes' ) AND (Relevant_Notes__c != ' ') ORDER BY Completed_Date_Time__c DESC];

//Populate MAP with WhatIDs to the list of events
For (Event e : lEvent){
      If(mAccEvent.get(e.whatID) == Null ) 
         mAccEvent.put(e.WhatID, e);
}

System.Debug('mAccEvent ' + mAccEvent);

for (Event updatedEvent : trigger.new) {   

System.Debug('updatedEvent.whatID = ' + updatedEvent.whatID);


If(mAccEvent.containsKey(updatedEvent.whatID) == TRUE) updatedEvent.Previous_Notes__c = mAccEvent.get(updatedEvent.whatID).Relevant_Notes__c  ; 
updatedEvent.Previous_Completed_Date_Time__c = mAccEvent.get(updatedEvent.whatID).Completed_Date_Time__c ;
}

//This should get most recent events with whatIDs that are the sames as all the whatIDs in the trigger. Then it will populate a map using those whatIDs. In the last for loop it will update each record in the trigger with the Previous_Notes__c value from the 1 event with a matching whatID. 

}

 

  • November 07, 2011
  • Like
  • 0
Hi All,

I am using Metadata API to get information about org. I want to retrieve all custom fields present in my org. I am using listMetadata() method which returns list of components. Below is my code:

MetadataService.MetadataPort service = createService();            
        List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();       
        MetadataService.ListMetadataQuery queryLayout = new MetadataService.ListMetadataQuery();
        //queryLayout.folder = MetaDataFolder;
        queryLayout.type_x ='CustomField';
        queries.add(queryLayout);      
        MetadataService.FileProperties[] fileProperties; 
        try{    
         fileProperties= service.listMetadata(queries, 29); //here 29 is api version
        }catch(exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,e.getMessage()));
        }

I am get exception as "IO Exception: Exceeded max size limit of 3000000". I know that number of custom fields present in my org is to much and the response that I am getting exceeding the allowed limit of 3MB. I want to list all custom fields present in my org. Same exception is coming when I am retrieving few other metadata(like all profile). Above mentioned code works fine in my developer org but in sandbox, its not working as number of metadata components is too much in my sandbox. 

I tried retrieving the components using Workbench which also uses metadata api. Workbench retrieved all components successfully. So there will be some mechanism in metadata API through which I can retrieve large number of components. I saw few post where people says to retrieve info in different chunks by spliting single request in 2 or 3 different request. But in my case, I am not able to split my request as I want all custom fields.

Can anyone help me on this .

Thanks in advance.

Regards,
Sunil kumar

Hi All,

 

I am storing a standard template(.csv file) which user can use to enter records and then they will upload file and then with the help of apex(controller) records will inserted in objects.

 

But the problem is when user download template from static resource its giving file in excel format but not in .csv format as file was stored in static resource as .csv format.

So can anyone help me with this issue and tell me where i am wrong?

 

Is there is any way to upload records by using excel file using apex(controllers)?

Hi All,

 

I want to create tree structure on vf page. My requirement is to crate tree structure for account and all related contacts. when user click on particular contact , contact detail page display in same page through partial page referesh.

 

Can any please help in achieving tree structure on VF page?

 

Thanks & Regards.

Hi all,

 

i want to pass id which i displayed in <apex:outputtext> on vf page to my javascript variable.

 

i used

var cc=document.getElementById('{!$Component.fromMain.pb2.outid}');

alert(cc);

 

my vf page code is

<apex:form id="fromMain">
<apex:pageBlock id="pb2">
  
    <apex:outputText id="outid" value="{!cid}" escape="false"/>

<apex:pageblock/>

<apex:form/>

 

in alert i am getting  [object HTMLSpanElement]

 

so i am not getting id value.

 

so can anyone help me in getting id value as i am getting id values from controller.

Hi everyone,

 

I had selected some leads in vf page and saved them in list in apex class code. when i navigate to other page, i am able to display selected records. Now my requirement is to change status of all selected leads by selecting values from status picklist and when i click on save,the status of all lead should change to selected option in picklist.

When i am using standard save button, i am getting required field missing i.e lastname and company............and when i am using custom save button then it throws exceptions!!!

 

i am using apex:inputfield in vf page for changing value of status.

 

So anyone can help me out in this requirement or can suggest how to write custom save method? 

Hi everyone,

 

I am selecting lead record in one visualforce page by using checkbox and storing the records in list in apex class. When i am directing my page to another page which uses same extension as that of previous page,size of list becomes zero means it doesnot contain any records when i navigate to other page. So i am not able to fetch record from list.

 

My requirement is to select lead record on one vf page by clicking on checbox and then displaying them in next vf page so that i can perform further actions.

 

Can anyone help me to get out of this problem? 

Hi all,

 

when I am clicking on my site i am getting this error page:

 

Limit Exceeded

Sorry for the inconvenience. Please email us if you need to get in touch.

 

Can anyone please tell why it is happening?

Hi all,

 

I want to embed partner portal login page into my visualforce page.

Can anyone please let me know how to do this?

Hi All,

I am using Metadata API to get information about org. I want to retrieve all custom fields present in my org. I am using listMetadata() method which returns list of components. Below is my code:

MetadataService.MetadataPort service = createService();            
        List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();       
        MetadataService.ListMetadataQuery queryLayout = new MetadataService.ListMetadataQuery();
        //queryLayout.folder = MetaDataFolder;
        queryLayout.type_x ='CustomField';
        queries.add(queryLayout);      
        MetadataService.FileProperties[] fileProperties; 
        try{    
         fileProperties= service.listMetadata(queries, 29); //here 29 is api version
        }catch(exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,e.getMessage()));
        }

I am get exception as "IO Exception: Exceeded max size limit of 3000000". I know that number of custom fields present in my org is to much and the response that I am getting exceeding the allowed limit of 3MB. I want to list all custom fields present in my org. Same exception is coming when I am retrieving few other metadata(like all profile). Above mentioned code works fine in my developer org but in sandbox, its not working as number of metadata components is too much in my sandbox. 

I tried retrieving the components using Workbench which also uses metadata api. Workbench retrieved all components successfully. So there will be some mechanism in metadata API through which I can retrieve large number of components. I saw few post where people says to retrieve info in different chunks by spliting single request in 2 or 3 different request. But in my case, I am not able to split my request as I want all custom fields.

Can anyone help me on this .

Thanks in advance.

Regards,
Sunil kumar

Hi All,

I am using Metadata API to get information about org. I want to retrieve all custom fields present in my org. I am using listMetadata() method which returns list of components. Below is my code:

MetadataService.MetadataPort service = createService();            
        List<MetadataService.ListMetadataQuery> queries = new List<MetadataService.ListMetadataQuery>();       
        MetadataService.ListMetadataQuery queryLayout = new MetadataService.ListMetadataQuery();
        //queryLayout.folder = MetaDataFolder;
        queryLayout.type_x ='CustomField';
        queries.add(queryLayout);      
        MetadataService.FileProperties[] fileProperties; 
        try{    
         fileProperties= service.listMetadata(queries, 29); //here 29 is api version
        }catch(exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,e.getMessage()));
        }

I am get exception as "IO Exception: Exceeded max size limit of 3000000". I know that number of custom fields present in my org is to much and the response that I am getting exceeding the allowed limit of 3MB. I want to list all custom fields present in my org. Same exception is coming when I am retrieving few other metadata(like all profile). Above mentioned code works fine in my developer org but in sandbox, its not working as number of metadata components is too much in my sandbox. 

I tried retrieving the components using Workbench which also uses metadata api. Workbench retrieved all components successfully. So there will be some mechanism in metadata API through which I can retrieve large number of components. I saw few post where people says to retrieve info in different chunks by spliting single request in 2 or 3 different request. But in my case, I am not able to split my request as I want all custom fields.

Can anyone help me on this .

Thanks in advance.

Regards,
Sunil kumar

Hi,

I am running below code from sandbox execute anonymous window. I am not getting any mail after execution.
Account a = new Account(name='Acme Plumbing');

insert a;

Contact c = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber', accountid=a.id);

insert c;

Database.DMLOptions dlo = new Database.DMLOptions();

dlo.EmailHeader.triggerAutoResponseEmail = true;

Case ca = new Case(subject='Plumbing Problems', contactid=c.id);

database.insert(ca, dlo);
This is exmaple from Salesforce documentation. Do I have to any setting? Could I request a help?

Thanks,


Not sure if this is a VF issue or Apex Code issue but I'm trying to create a table where the first two rows are opps related to the account and the next row(s) are for creating new opps.  I originally just had the table creating new opps and it worked fine but now we want to see a few existing ones as well to prevent duplicates.  So it must be something to do with my existing opps list...I just can't figure it out.  The controller saves fine but the VF page says Error: Unknown property 'VisualforceArrayList.CloseDate'.  If I remove closedate from the vf page it just gives the same error with the next field.  Somebody please help me figure this out.

Controller:
public class ForecastOpportunitiesController
{
public Account theAcc {get;set;}
public List<ForecastOpportunitiesWrapper> wrappers {get; set;}
public Opportunity[] existingopps {get;set;} { existingopps = new List<Opportunity>(); }
Public string accrecordId {get;set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}

private Integer nextIdent=1;

public ForecastOpportunitiesController(ApexPages.StandardsetController controller)

{
  accrecordid = ApexPages.CurrentPage().getparameters().get('id');

  // Query current opportunities
  existingopps = [
            select Id, Accountid, Name, Stagename, CloseDate
            from Opportunity
            where Accountid = :accrecordid order by CloseDate DESC Limit 2
        ];
      
  wrappers=new List<ForecastOpportunitiesWrapper>();
  for (Integer idx=0; idx<3; idx++)
  {
   wrappers.add(new ForecastOpportunitiesWrapper(nextIdent++));
  }
}

public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
 
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}

public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new ForecastOpportunitiesWrapper(nextIdent++));
  }
}

public PageReference save()
{
  List<Opportunity> opps=new List<Opportunity>();
  for (ForecastOpportunitiesWrapper wrap : wrappers)
  {
   opps.add(wrap.opp);
  }
 
  insert opps;
 
  return new PageReference('/' + ApexPages.currentPage().getParameters().get('Id'));
}

public PageReference onCancel(){

        // If user hits cancel we commit no changes and return them to the Account 
        return new PageReference('/' + ApexPages.currentPage().getParameters().get('Id'));
    }

public class ForecastOpportunitiesWrapper
{
  Public string recordId {get;set;}
  public Opportunity opp {get; private set;}
  public Integer ident {get; private set;}
 
  public ForecastOpportunitiesWrapper(Integer inIdent)
  {
   recordid = ApexPages.CurrentPage().getparameters().get('id');
   ident=inIdent;
   opp=new Opportunity(name='Forecast' + ident, Accountid=recordid, stagename='Forecast');
  }
}
}

VF Page:
<apex:page standardController="Opportunity"  recordSetVar="opps" extensions="ForecastOpportunitiesController" tabstyle="Opportunity">
<apex:form >
<apex:pageBlock title="Bulk Opportunity Create">
      <apex:pageBlockTable value="{!existingopps}" var="opps" id="wtable">
         <apex:column headerValue="Close Date">
            <apex:inputField value="{!opps.CloseDate}"/>
         </apex:column>
         <apex:column headerValue="Name">
            <apex:outputtext value="{!opps.Name}"/>
         </apex:column>
         <apex:column headerValue="Quantity">
            <apex:inputField value="{!opps.TotalOpportunityQuantity}" required="true"/>
         </apex:column>
         <apex:column headerValue="Stage">
            <apex:outputtext value="{!opps.StageName}"/>
         </apex:column>
      </apex:pageBlockTable>
   </apex:pageBlock>
   <apex:pageBlock title="Bulk Opportunity Create">
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
    <!--       <apex:column headerValue="Ident">-->
          <!--    <apex:outputText value="{!wrapper.ident}"/>-->
<!--           </apex:column>-->
         <apex:column headerValue="Close Date">
            <apex:inputField value="{!wrapper.opp.CloseDate}"/>
         </apex:column>
         <apex:column headerValue="Name">
            <apex:outputtext value="{!wrapper.opp.Name}"/>
         </apex:column>
         <apex:column headerValue="Quantity">
            <apex:inputField value="{!wrapper.opp.TotalOpportunityQuantity}" required="true"/>
         </apex:column>
         <apex:column headerValue="Stage">
            <apex:outputtext value="{!wrapper.opp.StageName}"/>
         </apex:column>
   <!--      <apex:column headerValue="Account"> -->
   <!--           <apex:outputtext value="{!wrapper.opp.Accountid}"/> -->
         <!--  </apex:column> -->
<!--          <apex:column headerValue="Action">-->
       <!--       <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">-->
             <!--    <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>-->
<!--              </apex:commandButton>-->
      <!--     </apex:column>-->
      </apex:pageBlockTable>
    <apex:commandButton value="Add Row" action="{!addRows}" rerender="wtable">
      <apex:param name="addCount" value="1" assignTo="{!addCount}"/>
      </apex:commandButton>
      <apex:commandButton value="Save" action="{!save}"/>
       <apex:commandButton action="{!onCancel}" value="Cancel" immediate="true"/>
   </apex:pageBlock>
</apex:form>
</apex:page>

Wrapper:
public class ForecastOpportunitiesWrapper
{

Public string recordId {get;set;}
public Opportunity opp {get; private set;}
public Integer ident {get; private set;}

public ForecastOpportunitiesWrapper(Integer inIdent)

{
  recordid = ApexPages.CurrentPage().getparameters().get('id');
  ident=inIdent;
  opp=new Opportunity(name='Forecast' + ident, accountid=recordid, stagename='Forecast');

 
}
}
Hi,
I have created an custom object product and it has so many field but the problem is that when i am trying to create a test class in which i am inserting date then it is giving error that the field is not writable.
     
     I have used formula in InHometrgtdateminus13days__c = In_Home_Target_Date__c-13
     Products__c ps = new Products__c();
      ps.ms_123postcards__Account__c = comp.id;
      ps.Fulfillment_Status__c = 'Currently in Design';
      ps.In_Home_Target_Date__c = system.today().adddays(13);
      ps.To_Finalize_Design__c = False;
      Ps.Do_not_repeat_finalize_design_task__c = FALSE;
      ps.Receive_New_Agreement__c = system.today().adddays(-1);
      ps.InHometrgtdateminus13days__c = system.today();
      insert ps;

     This error is giving when i am trying to insert ps.InHometrgtdateminus13days__c = system.today();

Can anyone help me to resolve this issue?
Hi All,

New to Salesforce Developmet and trying to replace the save button on my Visualforce page with a custom save button.

This is a custom object related to an Opportunity, when this object is saved I need it to update the lookup field on the opportunity to the ID of the object I'm saving.

Is this possible, can I update a seperate object when I save?

Thanks


public void attach() {
        try{
            Attachment myAttach = new Attachment();
            myAttach.ParentId = ApexPages.currentPage().getParameters().get('id');
            System.debug('Id: ' + ApexPages.currentPage().getParameters().get('id'));
            List<Attachment> at=[Select id from Attachment where parentId=:myAttach.ParentId];
            Integer c=at.size()+1;
            myAttach.name =D.Account__r.Name +''+ 'License Version' + c +'.pdf';
            PageReference psPdf = new PageReference('/apex/Quotation?id=' + ApexPages.currentPage().getParameters().get('id'));
            myAttach.body = psPdf.getContentAsPdf();

            insert myAttach;

 

In this i want to get the Google Docs, Notes, & Attachments ,,,Title Name when i attach Quotation by clicking the button

D.Account__r.Name +''+ 'License Version' + c +'.pdf';==aaa1.pdf

 

and when i attach manually finaldraft.doc

and when again i attach D.Account__r.Name +''+ 'License Version' + c +'.pdf';==aaa3.pdf but it should be aaa2.pdf

 

 

its urgent can u help me

Hello there,

 

I have a strange problem with <apex:outputPanel>, rendered="" attribute. In my controller, I have an Integer variable. On first load of the VF page, the value is non-negative. I have a search functionality, that causes to call {!onLoad} method. This method makes the value to 0(zero).  Now, when I try to rerender that outputPanel, its does't re-render even though the value of the variable is zero or negative.

 

Please help.

 

Thank you in advance.

 

This is VF <apex:outputPanel> :

 

<apex:outputpanel rendered="{!IF(volResultSide > 0, false, true)}">
<tr class="EvenRow" height="40px" style="padding-top:16px;padding-left: 15px;padding-right: 4px">
<td class="column">No Volunteers found!</td>
</tr>
</apex:outputpanel>

  • April 03, 2013
  • Like
  • 0

Hi All,

I am attempting to insert around 214 Tasks for contacts already in the system. I have 2 questions. 1. Would the body of the activity be considered a description? The information I want to Import include the Activity date, stutus, subject, and the body. I Also have contact id numbers associated with each.  2. The date format, It seems to be extremely partifular and keeps coming back with an error message saying the date is wrong. I have been researching and playing with this for a while and was hoping someone can show me what i'm missing.

I have created a Attachment Manager type setup, and the only thing is I am not able to pass the ID of the attachment to a new window.  It opens with nothing in it.

 

Any idea how I could fix this maybe?

 

   <apex:actionStatus id="status" startText="Searching... please wait..."/>
      <apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1">
        <apex:pageBlockTable value="{!searchResults}" var="item" rendered="{!NOT(ISNULL(searchResults))}">
        <apex:column headerValue="Delete">
            <apex:commandLink action="{!deleteAttachment}" onclick="if(!confirm('Are you sure?')) return false;">Del
                <apex:param value="{!item.id}" name="idToDel" assignTo="{!AttachId}"/>
            </apex:commandLink>
            </apex:column>
            <apex:column value="{!item.id}" HeaderValue="Attachment ID" width="100"/>
          <apex:column headerValue="Name of Attachment   (Click to view)" >
            <apex:outputLink value="{!URLFOR($Action.Attachment.Download,item.id)}" target="_blank">
            View</apex:outputLink>
            </apex:column>

 The code displays the list, as well as the option to Delete it, (and it works) however when I click on the View, it opens a new window but nothing is pulled over to view.  ?? Any idea?

Hi 

In visualforce page, i am displaying the Number(16,2) fields of salary, wages etc. currently its displaying like this 10,000.00

i need it without comma for i am adding these values dynamically and save on gross pay number field. during addition it takes first two digits of before comma, it takes 10,000.00 as 10. Is there any idea to solve this issue.

 

thank you.

Hi can any one suggest me the chanfes to mu code where it is necessary.

This was the complete error

First error: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []

 

Here is my code

 

global class MRUpdate2 implements Database.Batchable<sobject>,Schedulable {

global final string query= 'select id,Amount__c,name,End_Date__c,know_date__c,Today__c,contract__c,Email__c,Status__c,Start_Date__c from Maintanence_Renewal__c';
global final string email;
global MRUpdate2()
{

System.debug('--- Followers list: ' + query);
email='attelli.anilkumar@gmail.com';
}
global void execute(SchedulableContext SC) {
// invoke business logic - this method is strictly to invoke
// the method from the scheduler...
MRUpdate2 MR2 = new MRUpdate2();
ID batchprocessid = Database.executeBatch(MR2,10);

}
global Database.QueryLocator start(Database.BatchableContext BC)
{

return Database.getQueryLocator(this.query);
}

global void execute(Database.BatchableContext BC, List<Maintanence_Renewal__c> scope)
{
List<Maintanence_Renewal__c> MRSToUpdate = new List<Maintanence_Renewal__c>();

for(Maintanence_Renewal__c m :scope)
{
if(m.Today__c==m.know_date__c)
{
Maintanence_Renewal__c c2= new Maintanence_Renewal__c(Start_Date__c=m.End_Date__c,
Status__c='Pending',
contract__c=m.contract__c,Email__c=m.Email__C,
Amount__c=m.Amount__c+(m.Amount__c *5/100));
MRSToUpdate.add(c2);
}
}
update MRSToUpdate;
}
global void finish(Database.BatchableContext BC){
// Get the ID of the AsyncApexJob representing this batch job
// from Database.BatchableContext.
// Query the AsyncApexJob object to retrieve the current job's information.

AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
TotalJobItems, CreatedBy.Email
from AsyncApexJob where Id =:BC.getJobId()];

// Send an email to the contractor notifying about contract.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {email};
mail.setToAddresses(toAddresses);
mail.setSubject('Renew your contract');
mail.setPlainTextBody('Dear Sir/Madam please Renew Your Contract it will expire in 60 days' );

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}

}

 

Tnanks & Regards

Attelli

i have maintenence renewal objectwhen end date reaches to 60days before the end date it has to create a new record and send an email with some certain conditions which i mentioned in the code..

 

please help out this

 

global class MRUpdate implements  Database.Batchable<sObject> {

global final string query;

global MRUpdate (String q)
{
   query = q;
}

global Database.QueryLocator start(Database.BatchableContext BC){

   return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<Maintence_Renewal__c> scope)
{
  List<Maintence_Renewal__c> MRSToUpdate = new List<Maintence_Renewal__c>();
   MRSToUpdate=[select id,name,Start_Date__c,End_Date__c,testcontract__c,Email__C,
                 Amount__c from Maintence_Renewal__c ];
  for(Maintence_Renewal__c m :MRSToUpdate)
  {
  if(m.End_Date__c==(m.know_date__c))
    {
     m.Start_Date__c=MRSToUpdate.End_Date__c;
     m.testcontract__c=MRSToUpdate.testcontract__c;
     m.Email__c=MRSToUpdate.Email__C;
     m.Amount__c=MRSToUpdate.Amount__c+(MRSToUpdate.Amount__c *5/100);
    }
  }
}
global void finish(Database.BatchableContext BC){
  // Get the ID of the AsyncApexJob representing this batch job  
  // from Database.BatchableContext.    
  // Query the AsyncApexJob object to retrieve the current job's information.  

 AsyncApexJob a = [Select Id, Status, NumberOfErrors, JobItemsProcessed,
   TotalJobItems, CreatedBy.Email
   from AsyncApexJob where Id =:BC.getJobId()];

  // Send an email to the Apex job's submitter notifying of job completion.  
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
  String[] toAddresses = new String[] {a.CreatedBy.Email};
  mail.setToAddresses(toAddresses);
  mail.setSubject('Apex Sharing Recalculation ' + a.Status);
  mail.setPlainTextBody('The batch Apex job processed ' + a.TotalJobItems +
    ' batches with '+ a.NumberOfErrors + ' failures.');

  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}

}

 

Thanks&Regards

bhagi

  • July 05, 2012
  • Like
  • 0

I have an issue with a trigger that grabs a date/time value from one field (Field 1)and populates it in another (Field 2). The issue I run into is that if Field 1 is empty I get an error which I am guessing is cause you can insert a null value in a time/date field. Is there a to leave the field blank?

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger Previous_Notes caused an unexpected exception, contact your administrator: Previous_Notes: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Previous_Notes: line 27, column 1

 

trigger Previous_Notes on Event (before insert) {
    

Set<ID> trEvent = New Set<ID>();
Map<ID, Event> mAccEvent = New Map<ID, Event>();

//Get list of WhatIDs in trigger
for(Event e : trigger.new)
    trEvent.add(e.whatID);

List<Event> lEvent = [SELECT id, Event.WhatID,Event.Previous_Completed_Date_Time__c,Event.Completed_Date_Time_-c,Event.Previous_Notes__c,Event.Relevant_Notes__c FROM Event WHERE (whatID IN :trEvent) and (Subject = 'Outside Sales Call') and  (Sales_Call_Completed__c ='Yes' ) AND (Relevant_Notes__c != ' ') ORDER BY Completed_Date_Time__c DESC];

//Populate MAP with WhatIDs to the list of events
For (Event e : lEvent){
      If(mAccEvent.get(e.whatID) == Null ) 
         mAccEvent.put(e.WhatID, e);
}

System.Debug('mAccEvent ' + mAccEvent);

for (Event updatedEvent : trigger.new) {   

System.Debug('updatedEvent.whatID = ' + updatedEvent.whatID);


If(mAccEvent.containsKey(updatedEvent.whatID) == TRUE) updatedEvent.Previous_Notes__c = mAccEvent.get(updatedEvent.whatID).Relevant_Notes__c  ; 
updatedEvent.Previous_Completed_Date_Time__c = mAccEvent.get(updatedEvent.whatID).Completed_Date_Time__c ;
}

//This should get most recent events with whatIDs that are the sames as all the whatIDs in the trigger. Then it will populate a map using those whatIDs. In the last for loop it will update each record in the trigger with the Previous_Notes__c value from the 1 event with a matching whatID. 

}

 

  • November 07, 2011
  • Like
  • 0

Hi All,

 

I am storing a standard template(.csv file) which user can use to enter records and then they will upload file and then with the help of apex(controller) records will inserted in objects.

 

But the problem is when user download template from static resource its giving file in excel format but not in .csv format as file was stored in static resource as .csv format.

So can anyone help me with this issue and tell me where i am wrong?

 

Is there is any way to upload records by using excel file using apex(controllers)?

Hi All,

 

I want to create tree structure on vf page. My requirement is to crate tree structure for account and all related contacts. when user click on particular contact , contact detail page display in same page through partial page referesh.

 

Can any please help in achieving tree structure on VF page?

 

Thanks & Regards.

I am working on a project where I have a visualforce page opening from the opportunity to pick records from the customer product custom object and copying the record into object B and referencing the opportunity page. I am trying to pull the opportunity id onto the Visualforce page. I have been scouring the discussion boards and the new. All I could file is the Janascript code to go to the previous page for IE and have been playing with some sample code.

 

 public PageReference GoBack() {
  String previousPage = System.currentPageReference().getParameters().get(​history.go(-1));
    PageReference newPage = new PageReference(previousPage);
    newPage.setRedirect(true);
    return newPage;
  }

 

I know the above code is a shot in the dark. Can anyone help and point me in the right direction?

Hi all,

 

i want to pass id which i displayed in <apex:outputtext> on vf page to my javascript variable.

 

i used

var cc=document.getElementById('{!$Component.fromMain.pb2.outid}');

alert(cc);

 

my vf page code is

<apex:form id="fromMain">
<apex:pageBlock id="pb2">
  
    <apex:outputText id="outid" value="{!cid}" escape="false"/>

<apex:pageblock/>

<apex:form/>

 

in alert i am getting  [object HTMLSpanElement]

 

so i am not getting id value.

 

so can anyone help me in getting id value as i am getting id values from controller.

Hi, every one...
I'm thinking about making automatic proccess to import Excel file attached in Email to Salesoforce:

1. Invoke some APEX class when email comes to specific mail address.
2. Upload the attached Excel file in the email to document folder in Salesforce.
3. Invoke APEX code to read the data in Excel file and import the data to Salesforce Custom Object.
4. Notify the salesmanager that new custom list imported to Salesforce.

I appreciate so much if some one help me to know how I can do it.

Regards,

Akira Fujiwara