• Satyendra Rawat
  • NEWBIE
  • 203 Points
  • Member since 2013
  • Salesforce Developer

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 73
    Replies
Hi !

When I try to deploy my trigger. I'm getting this error:

Run Failures:
Email_abertura_de_vaga_test.myUnitTest001 System.DmlException: Update failed. First exception on row 0 with id 500U0000009g8I5IAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Email_abertura_de_vaga_case: execution of AfterUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

My trigger:

trigger Email_abertura_de_vaga_case on Case (after update) {

  
for(Case c : trigger.new){
    if (c.Func_abertura_chamado__c == 'THIAGO MARTINS' && c.motivo__c == 'Abertura de vaga' && c.resposta__c != null){

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          String[] toAddresses = new String[]{};  
            toAddresses.add('thiago.martins@cp7.com.br');
          mail.setToAddresses(toAddresses);
         
            mail.setSenderDisplayName('Vaga finalizada');
           
            mail.setreplyto ('alessandra.gomes@cp7.com.br');        
           
          mail.setSubject(''+c.Nome_atendimento__c+'');
          mail.setHtmlBody('Olá, tudo bem '+c.Func_abertura_chamado__c+'?<p>Segue informações de seu novo funcinário:</p><p><b>Vaga:</b> '+c.N_veis__c+'</p><p><b>Solicitante da vaga:</b> '+c.Func_abertura_chamado__c+'</p><p><b>Data de abertura da vaga:</b> '+c.CreatedDate.day()+'/'+c.CreatedDate.month()+'/'+c.CreatedDate.year()+'</p><p><b>Meios de divulgação:</b> '+c.Meios_de_divulga_o__c+'</p><p><b>Número de candidatos agendados:</b> '+c.Candidatos_agendados__c+'</p><p><b>Número de candidatos avaliados:</b> '+c.Candidatos_avaliados__c+'</p><p><b>Número de candidatos pré-selecionados:</b> '+c.Candidatos_pr_selecionados__c+'</p><p><b>Data de fechamento:</b> '+c.ClosedDate.day()+'/'+c.ClosedDate.month()+'/'+c.ClosedDate.year()+'</p><p><b>Candidato contatado:</b> '+c.Nome_atendimento__c+'</p><p><b>Data de início:</b> '+c.In_cio__c.day()+'/'+c.In_cio__c.month()+'/'+c.In_cio__c.year()+'</p><p><b>Observações:</b> '+c.resposta__c+'</p>');
           
          Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
      }
...



My test class:

@isTest (seeAllData=true)
public class Email_abertura_de_vaga_test {

static testMethod void myUnitTest001() {

Case ct = new Case();
    ct.Func_abertura_chamado__c = 'EVERTON GOMES';
    ct.motivo__c='Abertura de vaga';
    ct.subject='test';
    ct.Description='test test';
    ct.Nome_atendimento__c='Asassa';
    ct.N_veis__c='Auxiliar';
    ct.Meios_de_divulga_o__c='Asdfgh';
    ct.Candidatos_agendados__c=15;
    ct.Candidatos_avaliados__c=9;
    ct.Candidatos_pr_selecionados__c=1;
    ct.resposta__c=null;
insert ct;

ct.resposta__c='teste'; ct.Func_abertura_chamado__c = 'THIAGO MARTINS'; ct.motivo__c='Abertura de vaga';
ct.Nome_atendimento__c='Teste';
    ct.N_veis__c='Recepcionista';
    ct.Meios_de_divulga_o__c='TEste';
    ct.Candidatos_agendados__c=12;
    ct.Candidatos_avaliados__c=10;
    ct.Candidatos_pr_selecionados__c=2;
update ct;
     
}
HI,
I'm getting error"Too many SOQL queries: 101" in line User user1 = [Select id, Profile.Name from User where Id= :UserInfo.getUserId() ]; of code below :-
I have highlighted the line below.

//Method added for Sending AFD to Siebel 
  if(trigger.isBefore && trigger.isUpdate){
    Set<String> caOwnerId = new Set<String>();
    Map<Id,User> ownerRole = new Map<Id,User>();
    String s_profile = null; //Addition for Defect 13928
    for(Credit_Approval__c ca:trigger.new){
        caOwnerId.add(ca.OwnerId);
    }  
    if(caOwnerId.size()>0){
        ownerRole = new Map<Id,User>([select id,UserRole.Name from User where id = :caOwnerId]);   
    }
      
        User user1 = [Select id, Profile.Name from User where Id= :UserInfo.getUserId() ];
        s_profile = user1.Profile.Name;
     for(Credit_Approval__c ca:trigger.new){
          
          if(OwnerRole.get(ca.OwnerId)!=null && !'GE Integration User'.equalsIgnoreCase(s_profile)){
          //if(OwnerRole.get(ca.OwnerId)!=null{
                   if(OwnerRole.get(ca.OwnerId).UserRole!=null && OwnerRole.get(ca.OwnerId).UserRole.Name.contains('HFS')&& OwnerRole.get(ca.OwnerId).UserRole.Name.contains('Zone')){// HFS Project Change - Add null check
              ca.Flow_Struc__c = 'Flow';
            }
            if(OwnerRole.get(ca.OwnerId).UserRole!=null && OwnerRole.get(ca.OwnerId).UserRole.Name.contains('HFS')&& !OwnerRole.get(ca.OwnerId).UserRole.Name.contains('Zone')){// HFS Project Change - Add null check
              ca.Flow_Struc__c = 'Structured';
            }        
          }   
    } 
  }


}
  • February 12, 2014
  • Like
  • 0

Hi I'm stuck when it comes to gettting to 75% test coverage, the problem is testing a method that makes a SOAP request, 

 

I have tried to implment "HttpCalloutMock" without success an am getting the following error =

 

"System.XmlException: only whitespace content allowed before start tag and not [ (position: START_DOCUMENT seen [... @1:1)"

 

Tutorial I followed:

http://blogs.developerforce.com/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html

 

My classes that simply send a SOAP request to check if Login credentials are correct, Any help would be great.

 

public HttpResponse verify(){

System.debug('Username: '+username+' Password: '+password+' Domain: '+login_domain);
HttpRequest request = new HttpRequest();
Http h = new Http();

request.setEndpoint('https://' + login_domain + '.salesforce.com/services/Soap/u/29.0');
request.setMethod('POST');
request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
request.setHeader('SOAPAction', '""');
request.setBody(buildSoap(username,password));

HttpResponse res = h.send(request);
final Boolean verified = res.getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;

/*
final Boolean verified = (new Http()).send(request).getBodyDocument().getRootElement()
.getChildElement('Body','http://schemas.xmlsoap.org/soap/envelope/')
.getChildElement('loginResponse','urn:partner.soap.sforce.com') != null;
*/

if(verified) {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Correct Credentials!'));
}
else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Incorrect Credentials!'));
}
return res;
}

public String buildSoap(String username, String password){
XmlStreamWriter w = new XmlStreamWriter();
w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');
w.writeNamespace('', 'urn:partner.soap.sforce.com');
w.writeStartElement('', 'username', 'urn:partner.soap.sforce.com');
w.writeCharacters(username);
w.writeEndElement();
w.writeStartElement('', 'password', 'urn:partner.soap.sforce.com');
w.writeCharacters(password);
w.writeEndElement();
w.writeEndElement();

String xmlOutput =
'<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"><Body>'
+ w.getXmlString()
+ '</Body></Envelope>';
w.close();
return xmlOutput;
}

 

 

  • December 04, 2013
  • Like
  • 0

Hello All,

 

I am new to Salesforce.

We have this requirement.

 

a) We have a custom object that has 10 fields + 1-2 file attachments.

b) Expose this custom object via a webservice.The sole purpose of this webservice is to retrieve records from this custom object.

c) Our partner then ,using this webservice, will consume the records and load it in his system.

 

Is this possible to do it in Salesforce ?

@RestResource(urlMapping='/account')
global class TestRestServices {
    @HttpGet
    global static List<Property_Obj__c> getAccounts() {
       List<Property_Obj__c> lst;
       try
       {
        RestRequest req=RestContext.request;
        String namevalue=req.params.get('name');
        lst=[SELECT Send_From_Email__c,Listing_Sales_Associate__c,Buyer_0__c,Listing_Sales_Associate_Email__c,Seller_0__c,Listing_Broker__c,Address__c,Comm_B__c,County__c,Comm_S__c,
                Tax_Id__c,Coop_Sales_Assoc__c,Legal_Description_0__c,Offer_Date__c,PURCHACE_PRICE__c,HOA_Coa_Fee__c,Initial_Deposit__c,HOA_Coa_Freq__c,
                BALANCE_TOCLOSE__c,Terms_Num_Val__c,EXPIRATION_Date__c,Annual_Fee__c,Days_To_Close_After_Acceptance__c,city__c,Escrow_Name__c,zip__c,Escrow_Address__c,SS_Date2__c,
                Escrow_Phone__c,C_Date3__c,Escrow_Email__c,C2_Date4__c,Email_Fax__c,SS_Buyer2__c,INSPECT_PERIOD__c,C_Buyer3__c,OTHER_LINE_0__c,SS_Seller2__c,
                OTHER_LINE_2__c,C_Seller3__c,OTHER_LINE_3__c,SS_LD2__c,C_LD__c FROM Property_Obj__c where Status__c='Forward To E2P'];
         for(Property_Obj__c Acc:lst)
        {

              if(lst.size()>0)
              {
                 //Acc.Id=Id;
                 // Acc.Status__c ='Sent To E2P';
              }
           update Acc;
           }
        return lst;
       }catch(Exception e)
       {
       system.debug('Error'+e.getMessage());
       }
       return lst;
    }
}

  • November 30, 2013
  • Like
  • 0

Hi

I have 2 objects, purchase order(parent) and callup orders(child) lookup relation

 

in my parent object there is field called quantity

for one parent object i can create money child object,

in child object there is one field call up order,here i can enter the quantity ,

what i have to do is,if quantity cross more in my child object i need through error,

and i need to show balance in one field

right now am able to show error messag but am not able to shw balance

can u please tell me where am missing this is the my trigger

 

 

trigger Total_callup_order_Quantity on Call_Up_Order__c (after insert,after update)
{
   
    set<id> saleid=new set<id>();
    List<Call_Up_Order__c> calup=new List<Call_Up_Order__c>();
    
    if(trigger.isInsert || trigger.isUpdate)
    {
        for(Call_Up_Order__c co:trigger.new)
        {
             system.debug('-------Quote Quantity-------'+co.Quote_Quantity__c);
            saleid.add(co.Sale_Confirmation_Order__c);
        }
    }
    calup=[select id,Quote_Quantity__c,Balance_qty__c,Opp_pdt_detail_Quantity__c,Sale_Confirmation_Order__c,Call_Up_Quantity__c from Call_Up_Order__c  where Sale_Confirmation_Order__c in:saleid];
    
    system.debug('@@@@@@@@@!!!!!!!!!'+calup);
    decimal sum=0;
    decimal sum1=0;
    for(Call_Up_Order__c cp:calup)
    {
    
        sum=sum+cp.Call_Up_Quantity__c;
        
        
        if(cp.Sale_Confirmation_Order__c !=null)
        {
       cp.Balance_qty__c=cp.Quote_Quantity__c-sum;
            
        }
        system.debug('balnace qty m'+cp.Balance_qty__c);
        system.debug('@@@@@@@@@@@@ summmmm'+sum);
        if(sum >cp.Quote_Quantity__c)
        {
            system.debug('@@@@@@@@@');
            Trigger.New[0].adderror('you can not add more Quantity');
        }
    }
}

 

 

regards

venkatesh

Hi, can someone help me out with the following questions. Any help would be appreciated. 


1. A developer is writing a visualforce page to display a list of the checkbox fields found on a custom object.
    What is the recommended mechanism the developer should use to accomplish this?
   A.Schema Builder
   B.Metadata API
   C.Apex API
   D.Schema class
 
2.  How can a developer modify a highly interactive V.F page to be very responsive and work  
       on both desktop mobile devices?
   A.Use <apex:includeScript> with the standerd Salesforce1 javascript library.
   B.Use <apex:includeScript> with a custom javascript library.
   C.Use <apex:actionRegion> tags
   D.use <apex:actionSupport> tags
 
3.  Which Statement is true regarding both flow and Lightning Process?
    A.Are able to embedded directly into V.F pages
    B.Can use Apex methods with the @InvoicableMethod annotation
   C.Are both server-side considerations in the order of Execution
   D.Can use Apex that implements the Process.Plugin interface
 
4. A developer receives LimitException; too many query row:50001 error when running code
   what debugging approach using the developer console provides the fastest and most accurate mechanism
    to identity component that may be recruiting an unexpected number of rows?
     A.Add (                      ) to the code to track SOQL Query
     B.Filter the debug log on
 
5. A developer must create a way external parents to submit millions of leads into salesforce per day. How should the developer meet this requirement?
      A.publicity expose an apex web service via Force.com sites
      B.Create a web service on Heroku that uses Heroku Connect
      C.Publicity expose a V.F page via Force.com sites
      D.Host a web-to-lead form on the company websites
 
6. Which statement is true about using Chatter in Apex?
     choose 2 ans
    A.Chatter in Apex rate limits match Chatter rest API rate limits
    B.Chatter in Apex methods honor the with sharing and without sharing keywords
    C.Posting a photo in chatter in Apex is synchronous and happens immediatly
    D.Chatter in Apex methods do not run in system mode they run in the context of the current user

7. What is a best practice when unit testing a controller?
    choose 2 ans
    A.simulate best interaction by leveraging text.setMock{}
    B.Set.query parameters by using get.parameters{}.put{}
    C.Access test data by using testalldatatrue
    D.verify correct page references by using get.URL{}.
 
 
 
Has anyone completed this trail? I am stomped on challenge number 3, regarding created the process for fulfillment. Any pointers or guidance would be appreciated.
 
<apex:page Controller="TestPage_ctrl">
  <apex:form >
        <apex:outputPanel id="outputPane">
             {!IntegerStringMap}
                           <apex:outputPanel id="outputPanelId">
                            <apex:repeat value="{!IntegerStringMap}" var="a">
                                {!a}
                            </apex:repeat>
                     </apex:outputPanel>
                     </apex:outputPanel>
                     <apex:commandButton value="Add" action="{!addLotToConvert}" reRender="outputPane"/>
        </apex:form>
</apex:page>
public class TestPage_ctrl{

    public integer i { get ; set ;}
    public map<integer,String> IntegerStringMap { get; set; }
    
    public TestPage_ctrl(){
        i = 0;
        IntegerStringMap = new map<integer,String>();
        IntegerStringMap.put(i,'Test'+i);
    }
    
    public void  addLotToConvert(){
        i = i+1;
        IntegerStringMap.put(i,'Test'+i);
        //return null;
    }
}

When trying to use the Above code in Developer org it works as expected showing the Map contents and the Map Key as same. But when using this code in CS10/CS11 it does not. And there is a difference between the Contents and the Key of map.

 
Hello all.

I am stumped. I have set up a custom HTML email notification for people who register for our events. I hae placed the CSS styling in the head tag for the HTML and from the Email Template Preview window in SalesForce it looks perfect, but when I send a test email it comes into the inbox unformatted and with no styling.

What needs to be done to fix it? I've attched a screenshot of the two. You can see how its suppsed to look on the left from the view in SF. on the right is the test view in outlook.

I'm new to this stuff - so lamens terms would be great!

Example

Hi !

When I try to deploy my trigger. I'm getting this error:

Run Failures:
Email_abertura_de_vaga_test.myUnitTest001 System.DmlException: Update failed. First exception on row 0 with id 500U0000009g8I5IAI; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Email_abertura_de_vaga_case: execution of AfterUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

My trigger:

trigger Email_abertura_de_vaga_case on Case (after update) {

  
for(Case c : trigger.new){
    if (c.Func_abertura_chamado__c == 'THIAGO MARTINS' && c.motivo__c == 'Abertura de vaga' && c.resposta__c != null){

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
          String[] toAddresses = new String[]{};  
            toAddresses.add('thiago.martins@cp7.com.br');
          mail.setToAddresses(toAddresses);
         
            mail.setSenderDisplayName('Vaga finalizada');
           
            mail.setreplyto ('alessandra.gomes@cp7.com.br');        
           
          mail.setSubject(''+c.Nome_atendimento__c+'');
          mail.setHtmlBody('Olá, tudo bem '+c.Func_abertura_chamado__c+'?<p>Segue informações de seu novo funcinário:</p><p><b>Vaga:</b> '+c.N_veis__c+'</p><p><b>Solicitante da vaga:</b> '+c.Func_abertura_chamado__c+'</p><p><b>Data de abertura da vaga:</b> '+c.CreatedDate.day()+'/'+c.CreatedDate.month()+'/'+c.CreatedDate.year()+'</p><p><b>Meios de divulgação:</b> '+c.Meios_de_divulga_o__c+'</p><p><b>Número de candidatos agendados:</b> '+c.Candidatos_agendados__c+'</p><p><b>Número de candidatos avaliados:</b> '+c.Candidatos_avaliados__c+'</p><p><b>Número de candidatos pré-selecionados:</b> '+c.Candidatos_pr_selecionados__c+'</p><p><b>Data de fechamento:</b> '+c.ClosedDate.day()+'/'+c.ClosedDate.month()+'/'+c.ClosedDate.year()+'</p><p><b>Candidato contatado:</b> '+c.Nome_atendimento__c+'</p><p><b>Data de início:</b> '+c.In_cio__c.day()+'/'+c.In_cio__c.month()+'/'+c.In_cio__c.year()+'</p><p><b>Observações:</b> '+c.resposta__c+'</p>');
           
          Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
      }
...



My test class:

@isTest (seeAllData=true)
public class Email_abertura_de_vaga_test {

static testMethod void myUnitTest001() {

Case ct = new Case();
    ct.Func_abertura_chamado__c = 'EVERTON GOMES';
    ct.motivo__c='Abertura de vaga';
    ct.subject='test';
    ct.Description='test test';
    ct.Nome_atendimento__c='Asassa';
    ct.N_veis__c='Auxiliar';
    ct.Meios_de_divulga_o__c='Asdfgh';
    ct.Candidatos_agendados__c=15;
    ct.Candidatos_avaliados__c=9;
    ct.Candidatos_pr_selecionados__c=1;
    ct.resposta__c=null;
insert ct;

ct.resposta__c='teste'; ct.Func_abertura_chamado__c = 'THIAGO MARTINS'; ct.motivo__c='Abertura de vaga';
ct.Nome_atendimento__c='Teste';
    ct.N_veis__c='Recepcionista';
    ct.Meios_de_divulga_o__c='TEste';
    ct.Candidatos_agendados__c=12;
    ct.Candidatos_avaliados__c=10;
    ct.Candidatos_pr_selecionados__c=2;
update ct;
     
}
Hello All,

I want to process 1Lakh records by using batch class and intially I used default batch size to 200 but am getting some code issues 'System.ListException: Before Insert or Upsert list must not have two identically equal elements'..etc. If i restrict the batch size to '1' it is working fine.

 would like to know the batch execution time is depends on the batch size? If yes, please share the links if you have any!
batchprocessid = Database.executeBatch(batchclass,200); //Execution time
batchprocessid = Database.executeBatch(batchclass,1);     //Execution time


  • February 20, 2014
  • Like
  • 0
when i click on button in my vfpage this action is done but query is not getting to  show in my pageblocktable 


public void previous(){
        count++;
        system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5555555555555555555555555555'+count);
        cnt+=count;
        system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+cnt);
        myday=Date.today().addDays(-count);
        system.debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'+myday);
        showNextDay =true;
        date e=date.today();
        if(count!=null){
            contacts =[select id,First_Name__c,Mobile__c,LastName__c ,Patient_Id__c,Name,Country__c,Registration_Date__c,city__c,state__c,CreatedDate,status__c,opd_Reg_Date__c From OPD_Registration__c where  CreatedDate=LAST_N_DAYS:20 and status__c='open'];
        } 
       
       
     }
  • February 12, 2014
  • Like
  • 0
Hi am new to salesforce can any one please explane me how to use batch apex with simple examples
  • February 12, 2014
  • Like
  • 0
Hi,
I have page generate as PDF with huge amount of data. Due to the amount of data it sometimes fail (seems like timeout when loading the page, no excpetion on SF limitations).

I tried as solution to generate the page in memory and add as PDF attachment. Wrote small class (below) for testing and run it from the developer console.
When I run it for small data all is fine and its working.
But if I try it with huge data then, for some wired reason, I see that the page being generated over and over every minute (I see every minute call in the developer console), and add attachment per each run.

If I try it with very huge amount of the data, then also the page being generated every minute, but no pdf attachment is created (also can see internal error exception but without other information).

At first, I thought it's something in the code, but as it is working fine for small set of data, I'm thinking it's something internal for SF? Maybe someone have idea for this behavior?
+ Any other suggestions to enhance this process- to support huge data - will be welcome (I don't think it's related to crappy or un standard code, it's simply too much data, so I'm looking for general approach for this)

Thanks.

global class AddPdfToRecord{
   
    webservice static void addPDF(){
      
       pageReference pdf = Page.RepTestLiron;
      
      
       pdf.getParameters().put('cfr','test');
       pdf.getParameters().put('cto','');
       pdf.getParameters().put('del','');
       pdf.getParameters().put('efcont','A');;
       pdf.getParameters().put('hv','A');
       pdf.getParameters().put('repid','a1zD0000000L6WmIAK');
      
       system.debug('URL: ' + pdf.getURL());

       Attachment attach = new Attachment();
       Blob body;
       try
       {
           body = pdf.getContentasPDF();
       }
       catch(Exception e)
       {system.debug('EEEEEEEEEEEEEEEE'  + e) ;}
       attach.Body = body;
       attach.Name = 'FMR_TEST.pdf';
       attach.IsPrivate = false;
       attach.ParentId = '001D000000wqkSY';
           
        
        
       insert attach ;
    }
}
HI,
I'm getting error"Too many SOQL queries: 101" in line User user1 = [Select id, Profile.Name from User where Id= :UserInfo.getUserId() ]; of code below :-
I have highlighted the line below.

//Method added for Sending AFD to Siebel 
  if(trigger.isBefore && trigger.isUpdate){
    Set<String> caOwnerId = new Set<String>();
    Map<Id,User> ownerRole = new Map<Id,User>();
    String s_profile = null; //Addition for Defect 13928
    for(Credit_Approval__c ca:trigger.new){
        caOwnerId.add(ca.OwnerId);
    }  
    if(caOwnerId.size()>0){
        ownerRole = new Map<Id,User>([select id,UserRole.Name from User where id = :caOwnerId]);   
    }
      
        User user1 = [Select id, Profile.Name from User where Id= :UserInfo.getUserId() ];
        s_profile = user1.Profile.Name;
     for(Credit_Approval__c ca:trigger.new){
          
          if(OwnerRole.get(ca.OwnerId)!=null && !'GE Integration User'.equalsIgnoreCase(s_profile)){
          //if(OwnerRole.get(ca.OwnerId)!=null{
                   if(OwnerRole.get(ca.OwnerId).UserRole!=null && OwnerRole.get(ca.OwnerId).UserRole.Name.contains('HFS')&& OwnerRole.get(ca.OwnerId).UserRole.Name.contains('Zone')){// HFS Project Change - Add null check
              ca.Flow_Struc__c = 'Flow';
            }
            if(OwnerRole.get(ca.OwnerId).UserRole!=null && OwnerRole.get(ca.OwnerId).UserRole.Name.contains('HFS')&& !OwnerRole.get(ca.OwnerId).UserRole.Name.contains('Zone')){// HFS Project Change - Add null check
              ca.Flow_Struc__c = 'Structured';
            }        
          }   
    } 
  }


}
  • February 12, 2014
  • Like
  • 0
hi i created one object called registration in that i have name, email,username,password   i created one registration vf page with name, email,username,password   and with save button when i click on save button its saveing in database. then i created one login vfpage in that i have username and password and login button once i click on login button  need to compare username password with registered username password if match need show another page  please help any one with this
  • February 06, 2014
  • Like
  • 0

hello :) i searched this code to prevent duplication of records in an object.

trigger PreventFuelDuplication on Fuel__c (before insert, before update) {
    Map<String, Fuel__c> leadMap = new Map<String, Fuel__c>();
    for (Fuel__c lead : System.Trigger.new) {
           
        if ((lead.Name != null) && (System.Trigger.isInsert || (lead.Name != System.Trigger.oldMap.get(lead.Id).Name))) {
            if (leadMap.containsKey(lead.Name)) {
                lead.Name.addError('This Fuel already exists.');
            } else {
                leadMap.put(lead.Name, lead);
            }
       }
    }
   
    for (Fuel__c lead : [SELECT Name FROM Fuel__c WHERE Name IN :leadMap.KeySet()]) {
        Fuel__c newLead = leadMap.get(lead.Name);
        newLead.Name.addError('This Fuel already exists.');
    }
}

i need to create a test class for this and i have no idea how. can anyone help me please?

 

  • December 24, 2013
  • Like
  • 0

Hi there,

 

I am having wrapper class in apex class, i need to pass more than 32 (like 40) parameters to wrapper constructor.

When i was passing more than 32 parameters I am getting you cannot pass more than 32 parameters to wrapper constructor.

Can anyone please tell how can i pass more than 32 parameters?

 

Any idea or sample please.

 

Thank you,

I can i associate a apex class with a apext test class?

 

My class

public class NewContact{

public void getopportunity(){
}
}

 

Test Class

@isTest
public class NewContactTest{
@isTest static void Testgetopportunity() {
}
}

 

in force.ide i do see none with Code coverage tab.

 

 

Regard's

Shanker Paudel

Hi,

 

<apex:page Controller="selectst" >
<apex:form >
<apex:selectList value="{!str}">
<apex:selectOptions value="{!values}" />





</apex:selectList>

</apex:form>
</apex:page>

 

 

 

Controller :--------------

public class selectst {


public List<SelectOption> getValues() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}

 

public string str {get;set;}

}

 

Can any one help me?

 

Hi All,

 

I have a code with passing id  to apex class via visualforce page URL methode and that id i need to pass to another class.i will past the code for the same but its not working.Thanks in advance.

 

page one:

<apex:commandLink value="{!applicant.Deal_Name__c}"
                            action="/apex/Deal_Items?id={!applicant.Deal_Name__c}"> //by passing url to another page
                            <apex:param name="id" value="{!applicant.Deal_Name__c}" />

                        </apex:commandLink>

 

page two

{

//getting the id here but its not to getting page two Component controlle

 

}

 

page two controller:

public class pagetwocontroller{
 public String selectedName {get;set;}  
 public pagetwocontroller()  
 {  
   selectedName = ApexPages.currentPage().getParameters().get('id');  
 }

// some codes  

}

 

page two Component controller: 

{

 

how to get page-two-controller id  to this controller.

 

}

 

 

 

 

 

I'll give certification exam this week. Please solve me these questions if you know

How does Salesforce enforce data access using role hierarchy?
a. Users are given access to the records owned by the users who are
below them in the role hierarchy
b. Users are given access to the records owned by the users who share
the same role in the role hierarchy
c. Users are given access to the records accessible by the users who are
below them in the role hierarchy
d. Users are given access to the records accessible by the users who are
above the role hierarchy

 

What will cause the analytic snapshots run to fail?
Please select three (3) choices.
a. The source report has been deleted
b. The target object has a trigger on it
c. The running user has been inactivated
d. The target object is a custom object
e. The source report is saved as matrix report

 

Thanks 

Souvik

How can make ajax request using jQuery in VisulForce to Apex ?

 

Example

 $.ajax({

type :"POST",
url :'Apex-url',
dataType :"json",
success:function(data){
alert( data );
},
error :function(){
alert("Sorry, The requested property could not be found.");
}
});

Hi

We have implemented logout functioanlity by adding script "/secur/logout.jsp" to visualforce page for force.com sites. But whenever we logout, it is going to Sales force logout page and then going to login page. As per requirement we dont want to show sales force logout page. please let me is there any java script or other scipt to change the behavior.

 

Thanks,

Ravikumar Katragunta

  • June 07, 2011
  • Like
  • 0

Hi,

 

I want to ask a question, is it possible to format the date field in Email template? Any suggestions would be great.

 

 

regards,

 

Edwin

I am trying to invoke system.schedule method. The first parameter is name of the schedule, second is the schedule string and third is the instance of the apex class that implements Schedulable interface.

 

The schedule string is the following

 

'58 0 20 12 5 ? 2010'

 

I get an exception saying System.Exception: trigger must be associated with a job detail

 

Has anyone encountered this exception before? Any idea where i could be missing? Any help would be appreciated.

 

3:0:57.407|METHOD_ENTRY|[109,32]|system.schedule(String, String, scheduleActiveQChecker)
3:0:57.450|EXCEPTION_THROWN|[109,32]|System.Exception: trigger must be associated with a job detail
3:0:57.450|METHOD_EXIT|[109,32]|schedule(String, String, APEX_OBJECT)