• Techies
  • NEWBIE
  • 26 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 13
    Replies

HI,

  I wrote a trigger on case object . In that I am having a custom formula filed which caliculates the case age.

i wrote the next logic based on the case age field when the age is 22 hrs. So when the age is 22 hrs i am making a boolean value as true then process the rest of the logic.. but i can't set the age to 22 na..... So how to achieve my code coverage.  please give me an ides... Thank ful to you

 

 

Regards,

 

Kiran

Is there any possiblity to place a dashboard in to a vf page? if yes just post me the idea to implement.

 

 

Thank you..

 

 

Regards,

 

kiran

Can any tell me that, how to keep a mail to sfdc people for enabling the @RemoteAction in my Developer Edition

  • February 19, 2011
  • Like
  • 0

For some reason, I have to catch the event when a user is leaving a visualforce page (closing the page, clicking on another link, ...) and execute a method of my controller.

The idea was to use something like window.onbeforeunload = function(){ Unload();return false} which should call the function "unload()". It's working pretty well when I replace the "Unload()" with a javascript alert, meaning the function is executed but the aim is to call the controller... So I have a simple actionfunction  <apex:actionFunction action="{!OnUnload}" name="Unload"/> which should call the method "OnUnload" in my controller. Unfortunately, it is not working... It's not the first time I'm using actionfunction called from Javascript but it looks like that the line "actionfunction" is already "unloaded" even on "onbeforeunload" :/

Has someone already been confronted to this problem ?? 

Is it something like this?

 

// every 5 minutes
String sch = '0 5 * * * ? ';

 

I am a SFDC administrator.

My boss wants the system to automatic send him a notice once there is a new opportunity (donation) coming in.

Our new opportunity is generated through

 

  1. regular input data into an object
  2. salesforce data loader
  3. batch data entry (by using the object "batches")

I am trying to build a workflow, so once there is a new opportunity, an email delivery will be triggered.

 

However, the SFDC support analyst said it is IMPOSSIBLE to trigger workfolow rules uising Apex Data Loader or Batch processes.

 

I was wondering how I could solve the problem?

 

Thank you

Stan

Hi,

 

  This is kumar, I’m new to salesforce. I need to call an external application from Apex through HTTP Call outs. Could any one send me the sample code, how to parse and call (invoke) external application(wsdl). Any help must be appreciated .

 

 

Thanks inadvance!

Kumar

Hi Friends,


I have created a Schedulable job.
Apex Class is :

global class scheduledUpdateOnOppurtunity implements Database.Batchable<SObject>, Database.AllowsCallouts{
public String query ;
public Date currentDate =  date.today();
public Integer monthDays =  date.daysInMonth(currentDate.year(), currentDate.month())-1;
public Date startOfMonth = currentDate.toStartOfMonth();
public Date endOfMonth = startOfMonth.addDays(monthDays);         
public Integer currentFinancialYear = currentDate.year();
public date currentQuarterStart;
public date currentQuarterEnd;
public date firstQuarterStart;
public date firstQuarterEnd;
public date secondQuarterStart;
public date secondQuarterEnd;
public date thirdQuarterStart;
public date thirdQuarterEnd;
public date forthQuarterStart;
public date forthQuarterEnd;

global database.Querylocator start(Database.BatchableContext BC){
       query = 'SELECT CloseDate, Closed_date_Today__c,Closed_date_StartOfMonth__c, Closed_date_EndOfMonth__c, Closed_date_CurrentQuarterStart__c, Closed_date_CurrentQuarter__c from Opportunity WHERE isClosed = false';
       return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC,Sobject[] scope)
{
          if(currentDate.month() <=3 ){
              currentFinancialYear = currentDate.year() - 1;
          }
          firstQuarterStart = date.newInstance(currentFinancialYear, 04, 01);
          firstQuarterEnd = date.newInstance(currentFinancialYear, 06, 30);
          secondQuarterStart = date.newInstance(currentFinancialYear, 07, 01);
          secondQuarterEnd = date.newInstance(currentFinancialYear, 09, 30);          
          thirdQuarterStart = date.newInstance(currentFinancialYear, 10, 01);
          thirdQuarterEnd = date.newInstance(currentFinancialYear, 12, 31);          
          forthQuarterStart = date.newInstance(currentFinancialYear+1, 01, 01);
          forthQuarterEnd = date.newInstance(currentFinancialYear+1, 03, 31);              
          if (currentDate >= firstQuarterStart && currentDate <= firstQuarterEnd ){
              currentQuarterStart = firstQuarterStart;
              currentQuarterEnd = firstQuarterEnd;
          }
          if (currentDate >= secondQuarterStart && currentDate <= secondQuarterEnd ){
              currentQuarterStart = secondQuarterStart;
              currentQuarterEnd = secondQuarterEnd;
          }
          if (currentDate >= thirdQuarterStart && currentDate <= thirdQuarterEnd ){
              currentQuarterStart = thirdQuarterStart;
              currentQuarterEnd = thirdQuarterEnd;
          }
          if (currentDate >= forthQuarterStart && currentDate <= forthQuarterEnd ){
              currentQuarterStart = forthQuarterStart;
              currentQuarterEnd = forthQuarterEnd;
          }         
            
           try{
                List<Opportunity> listOppUpdate = new List<Opportunity>();
                           
                 for(sobject s : scope){
                      Opportunity opp = (Opportunity)s;
                if (opp.CloseDate > currentDate){
                    opp.Closed_date_Today__c = true;
                }else{        
                    opp.Closed_date_Today__c = false;
                }
                if (opp.CloseDate >= startOfMonth){
                    opp.Closed_date_StartOfMonth__c = true;
                }else{
                    opp.Closed_date_StartOfMonth__c = false;
                }
                if (opp.CloseDate <= endOfMonth){
                    opp.Closed_date_EndOfMonth__c = true;
                }else{
                    opp.Closed_date_EndOfMonth__c = false;
                }
                if(opp.CloseDate >= currentQuarterStart){
                    opp.Closed_date_CurrentQuarterStart__c = true;
                }else{
                    opp.Closed_date_CurrentQuarterStart__c = false;
                }         
                if(opp.CloseDate <= currentQuarterEnd){
                    opp.Closed_date_CurrentQuarter__c = true;
                }else{
                    opp.Closed_date_CurrentQuarter__c = false;
                }     
                    
                   listOppUpdate.add(opp);
                    
                   if(listOppUpdate.size() > 999){
                       database.update(listOppUpdate,false);
                        listOppUpdate = new List<Opportunity>();
                   }
                 }
                 
                 if(listOppUpdate.size() > 0){
                     database.update(listOppUpdate,false);
                 }
                 
              }
              catch(Exception ex){
                  system.debug(ex.getMessage());
              }  
      
  }
  global void finish(Database.BatchableContext BC){
  }
}

Code coverage is 32% only. How I can improve this coverage?

I'm adding Test Class in my second message.

Hello,

 

I need to call an Apex web service that will be invoked from an external system. To test this out, I am trying to call this webservice from apex class generated from WSDL file.

 

I have performed the following steps:

 

* Developed  the global apex webservice class called ‘Billing Integration’. Its code snippet is as follows:

 

global class Billing_Integration{
    WebService static String Import(String input,Integer Action) {
        String result;
        Integration__c i = new Integration__c();
        if(Action == 1){
            OpenCsvParser.StringBuilder sb = new OpenCsvParser.StringBuilder();
            List<account> accounts = new List<account>();
            sb.append(input);
            OpenCsvReader reader = new OpenCsvReader(new OpenCsvParser(),sb.asString(),'\n');

* Downloaded its WSDL file in xml format using the WSDL link on the class name.

 

* Generated the Apex Class called ‘soapSforceComSchemasClassBillingIn’ from its WSDL file.

 

Is this approach right?

 

Now I don’t know how to call webservice class ‘Billing Integration’ through newly generated apex class ‘soapSforceComSchemasClassBillingIn’. 

Plz help.

 

 

HI,

  I wrote a trigger on case object . In that I am having a custom formula filed which caliculates the case age.

i wrote the next logic based on the case age field when the age is 22 hrs. So when the age is 22 hrs i am making a boolean value as true then process the rest of the logic.. but i can't set the age to 22 na..... So how to achieve my code coverage.  please give me an ides... Thank ful to you

 

 

Regards,

 

Kiran

Hi,

 

I need to create a pdf file and insert it to the attachment object as record. This would fire as a scheduled class and not on a button click in a Visualforce page.

The code is as below:

 

global class OrderDispatchToTopcall implements Schedulable{
/*
        Author            : Cognizant
        Functionality     : This is a helper class is for the creation of the Order Dispatch pdf file and attach to the batch object.
                            The class acts as a controller class for the pdf generation.
                            Fetches data from the objects like Purchase order, Job Elements, Supplier
        Create Date       : 15 May 2010
        Change History    :
        Modified Date     :
    */
global void execute(SchedulableContext SC) {
PageReference pdf =  Page.MerchantDeliveryChecklist;
     pdf.getParameters().put('id', 'a1CR000000044H8');
     pdf.getParameters().put('pageType', 'NCHODC');
     pdf.setRedirect(true);
     Blob b=pdf.getContentAsPDF();
    
     Attachment attachment=new Attachment(ParentId='a1CR000000044H8',body=b,ContentType='application/pdf',Name='test.pdf');
     insert  attachment;
}
}

global class OrderDispatchToTopcall implements Schedulable{

 global void execute(SchedulableContext SC) {

 PageReference pdf =  Page.MerchantDeliveryChecklist;    

pdf.getParameters().put('id', 'a1CR000000044H8');    

 pdf.getParameters().put('pageType', 'NCHODC');    

 pdf.setRedirect(true);    

 Blob b=pdf.getContentAsPDF();      

  Attachment attachment=new Attachment(ParentId='a1CR000000044H8',body=b,ContentType='application/pdf',Name='test.pdf');    

insert  attachment;

 }

}

 

When this class runs it creates an attachment record but it is in a invalid format.

But when I call the same PDF creation code from button on a visualforce page, the attachment is created and it is a valid file.

 

Can somebody help me why I am not able to create a valid pdf file when the code runs from a schedular

 

hi
 
can u please tell me how to generate a visual force page in word document.
Hey  guys ,
I m going through the DML statements  in Apex code  , while using merge call in my class i got stuck
Im executing through my S-control in this manner
S-Control
var name = "Aman";
 var name1="Acme";
var merge_demo = sforce.apex.execute("DML","Mer_demo",{arg:name},{arg1:name1});

Class
webService static Account[] Mer_demo(String arg,String arg1)
       {
            String[] ss = new String[]{arg};
            String[] yy = new String[]{arg1};
            Account[] masterAcc = [select id,name from account where name in :ss ];
            Account[] mergeAcc = [select id,name from account where name in : yy ];
         
           try{
                merge masterAcc mergeAcc ;
            }
            catch(System.DmlException e)
            {
                alert(e);
                // process exception
            }
           
            return masterAcc;
       }

when i  execute this i got error and it didn't execute ,
anyone can help me in this

plz suggest
thx
Aman Sehgal
  • December 10, 2007
  • Like
  • 0