• Sanjeev SFDC
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi  I'm Trying  deploy this trigger but it is showing exception can any one will help in this
Trigger

  1. trigger convertNumbersToWords on Transaction__c(before update) {
  2.     String[] units=new String[]{'',' One',' Two',' Three',' Four',' Five',' Six',' Seven',' Eight',' Nine'};
  3.     String[] teen=new String[]{' Ten',' Eleven',' Twelve',' Thirteen',' Fourteen',' Fifteen',' Sixteen',' Seventeen',' Eighteen',' Nineteen'};
  4.     String[] tens=new String[]{' Twenty',' Thirty',' Fourty',' Fifty',' Sixty',' Seventy',' Eighty',' Ninety'};
  5.     String[] maxs=new String[]{'','',' Hundred',' Thousand',' Lakh',' Crore'};
  6.     For(Transaction__c T : trigger.new){
  7.     if(t.Net_Supplementary_Amount__c >0){
  8.       t.Net_Suppl_Interset_words__c =convert(integer.valueof(t.Net_Supplementary_Amount__c)) ;}
  9.        else{
  10.               t.Net_Suppl_Interset_words__c=' ';
  11.           }  
  12.       
  13.        t.Net_Supplementary_Brokerage_in_words__c =convert(integer.valueof(t.Net_Suppl_Brokerage__c)) ;
  14.        t.Net_Interest_till_31st_March_in_words__c =convert(integer.valueof(t.Interest_pre_31_Mar__c));
  15.        t.Net_Interest_post_31st_March_in_words__c =convert(integer.valueof(t.Intrst_post_31_Mar__c));
  16.        t.Net_Brokerage_Amt_in_Words__c =convert(integer.valueof(t.Net_Brokerage_INR__c));
  17.       
  18.     }
  19.   
  20.    
  21.     public string digitsToWord(string val){
  22.         String Convertedtext='';
  23.         list<string> Vallist=val.split('');
  24.                 string sss=Vallist.remove(0);
  25.         for(integer i=Vallist.size()-1;i>=0;i--){
  26.             integer index=integer.valueof(Vallist[i]);
  27.             if(i==0&&index>1&&Vallist.size()>1)
  28.                  Convertedtext=tens[index-2]+Convertedtext;
  29.             else if(i==0&&index==1&&Vallist.size()==2){
  30.                 integer sum=0;
  31.                 for(integer j=0;j<2;j++){
  32.                      sum=(sum*10)+integer.valueof(Vallist[j]);
  33.                 }
  34.                 return teen[sum-10]; 
  35.             }
  36.             else{
  37.                
  38.                  if(index>0)
  39.                      Convertedtext=units[index]+Convertedtext;
  40.             }
  41.         }
  42.         return Convertedtext;
  43.     }
  44.    
  45.    public String convert(integer n) {
  46.        if(n==0)
  47.            return 'Zero';
  48.         if(n>999999999)
  49.             return 'More then 100 corers ';
  50.        string amount=string.valueOf(n);
  51.       
  52.        integer positioning=1;
  53.        boolean IsHundred=false;
  54.        string Convertedtext='';
  55.        while(amount.length()>0){
  56.            if(positioning==1){
  57.                if(amount.length()>=2){
  58.                    String C=amount.substring(amount.length()-2,amount.length());
  59.                    amount=amount.substring(0,amount.length()-2);
  60.                    Convertedtext+=digitsToWord(C);
  61.                } else if(amount.length()==1){
  62.                     Convertedtext+=digitsToWord(amount);
  63.                     amount='';
  64.                }positioning++;
  65.            }
  66.            else if(positioning==2){
  67.                String C=amount.substring(amount.length()-1,amount.length());
  68.                amount=amount.substring(0,amount.length()-1);
  69.                if(Convertedtext.length()>0&&digitsToWord(C)!=''){
  70.                    Convertedtext=(digitsToWord(C)+maxs[positioning]+' and')+Convertedtext;
  71.                    IsHundred=true;
  72.                }
  73.                else{
  74.                    if(digitsToWord(C)!='')
  75.                      Convertedtext=(digitsToWord(C)+maxs[positioning])+Convertedtext;IsHundred=true;
  76.                }
  77.                positioning++;
  78.            }
  79.            else if(positioning>2){
  80.                if(amount.length()>=2){
  81.                    String C=amount.substring(amount.length()-2,amount.length()); amount=amount.substring(0,amount.length()-2);
  82.                    if(!IsHundred&&Convertedtext.length()>0)
  83.                        Convertedtext=digitsToWord(C)+maxs[positioning]+' and'+Convertedtext;
  84.                    else{ if(digitsToWord(C)=='') {} else Convertedtext=digitsToWord(C)+maxs[positioning]+Convertedtext; }
  85.                } else if(amount.length()==1){
  86.                    if(!IsHundred&&Convertedtext.length()>0)
  87.                        Convertedtext=digitsToWord(amount)+maxs[positioning]+' and'+Convertedtext; 
  88.                    else{ if(digitsToWord(amount)==''){}else Convertedtext=digitsToWord(amount)+maxs[positioning]+Convertedtext;   amount='';  }
  89.                   
  90.                }
  91.                 positioning++;
  92.            }
  93.         }
  94.       
  95.    return Convertedtext;
  96.    }
  97.    
  98. }
  99.  
  100.  
  101.  
  102.  

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, convertNumbersToWords: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.convertNumbersToWords: line 55, column 1 Trigger.convertNumber...
 

Hi,
     i have two users  one user is using currency as Rupee and another user is using Dollar,if i'm generating pdf for these currency fileds how to get the currency symbols for ( U S user $, indian User Rupee) automatically .



Thanks,
Sanjeev

Hi,
     I need to integrate Truecaller to Salesforce is it possible
Hi  I'm Trying  deploy this trigger but it is showing exception can any one will help in this
Trigger

  1. trigger convertNumbersToWords on Transaction__c(before update) {
  2.     String[] units=new String[]{'',' One',' Two',' Three',' Four',' Five',' Six',' Seven',' Eight',' Nine'};
  3.     String[] teen=new String[]{' Ten',' Eleven',' Twelve',' Thirteen',' Fourteen',' Fifteen',' Sixteen',' Seventeen',' Eighteen',' Nineteen'};
  4.     String[] tens=new String[]{' Twenty',' Thirty',' Fourty',' Fifty',' Sixty',' Seventy',' Eighty',' Ninety'};
  5.     String[] maxs=new String[]{'','',' Hundred',' Thousand',' Lakh',' Crore'};
  6.     For(Transaction__c T : trigger.new){
  7.     if(t.Net_Supplementary_Amount__c >0){
  8.       t.Net_Suppl_Interset_words__c =convert(integer.valueof(t.Net_Supplementary_Amount__c)) ;}
  9.        else{
  10.               t.Net_Suppl_Interset_words__c=' ';
  11.           }  
  12.       
  13.        t.Net_Supplementary_Brokerage_in_words__c =convert(integer.valueof(t.Net_Suppl_Brokerage__c)) ;
  14.        t.Net_Interest_till_31st_March_in_words__c =convert(integer.valueof(t.Interest_pre_31_Mar__c));
  15.        t.Net_Interest_post_31st_March_in_words__c =convert(integer.valueof(t.Intrst_post_31_Mar__c));
  16.        t.Net_Brokerage_Amt_in_Words__c =convert(integer.valueof(t.Net_Brokerage_INR__c));
  17.       
  18.     }
  19.   
  20.    
  21.     public string digitsToWord(string val){
  22.         String Convertedtext='';
  23.         list<string> Vallist=val.split('');
  24.                 string sss=Vallist.remove(0);
  25.         for(integer i=Vallist.size()-1;i>=0;i--){
  26.             integer index=integer.valueof(Vallist[i]);
  27.             if(i==0&&index>1&&Vallist.size()>1)
  28.                  Convertedtext=tens[index-2]+Convertedtext;
  29.             else if(i==0&&index==1&&Vallist.size()==2){
  30.                 integer sum=0;
  31.                 for(integer j=0;j<2;j++){
  32.                      sum=(sum*10)+integer.valueof(Vallist[j]);
  33.                 }
  34.                 return teen[sum-10]; 
  35.             }
  36.             else{
  37.                
  38.                  if(index>0)
  39.                      Convertedtext=units[index]+Convertedtext;
  40.             }
  41.         }
  42.         return Convertedtext;
  43.     }
  44.    
  45.    public String convert(integer n) {
  46.        if(n==0)
  47.            return 'Zero';
  48.         if(n>999999999)
  49.             return 'More then 100 corers ';
  50.        string amount=string.valueOf(n);
  51.       
  52.        integer positioning=1;
  53.        boolean IsHundred=false;
  54.        string Convertedtext='';
  55.        while(amount.length()>0){
  56.            if(positioning==1){
  57.                if(amount.length()>=2){
  58.                    String C=amount.substring(amount.length()-2,amount.length());
  59.                    amount=amount.substring(0,amount.length()-2);
  60.                    Convertedtext+=digitsToWord(C);
  61.                } else if(amount.length()==1){
  62.                     Convertedtext+=digitsToWord(amount);
  63.                     amount='';
  64.                }positioning++;
  65.            }
  66.            else if(positioning==2){
  67.                String C=amount.substring(amount.length()-1,amount.length());
  68.                amount=amount.substring(0,amount.length()-1);
  69.                if(Convertedtext.length()>0&&digitsToWord(C)!=''){
  70.                    Convertedtext=(digitsToWord(C)+maxs[positioning]+' and')+Convertedtext;
  71.                    IsHundred=true;
  72.                }
  73.                else{
  74.                    if(digitsToWord(C)!='')
  75.                      Convertedtext=(digitsToWord(C)+maxs[positioning])+Convertedtext;IsHundred=true;
  76.                }
  77.                positioning++;
  78.            }
  79.            else if(positioning>2){
  80.                if(amount.length()>=2){
  81.                    String C=amount.substring(amount.length()-2,amount.length()); amount=amount.substring(0,amount.length()-2);
  82.                    if(!IsHundred&&Convertedtext.length()>0)
  83.                        Convertedtext=digitsToWord(C)+maxs[positioning]+' and'+Convertedtext;
  84.                    else{ if(digitsToWord(C)=='') {} else Convertedtext=digitsToWord(C)+maxs[positioning]+Convertedtext; }
  85.                } else if(amount.length()==1){
  86.                    if(!IsHundred&&Convertedtext.length()>0)
  87.                        Convertedtext=digitsToWord(amount)+maxs[positioning]+' and'+Convertedtext; 
  88.                    else{ if(digitsToWord(amount)==''){}else Convertedtext=digitsToWord(amount)+maxs[positioning]+Convertedtext;   amount='';  }
  89.                   
  90.                }
  91.                 positioning++;
  92.            }
  93.         }
  94.       
  95.    return Convertedtext;
  96.    }
  97.    
  98. }
  99.  
  100.  
  101.  
  102.  

Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, convertNumbersToWords: execution of BeforeUpdate caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.convertNumbersToWords: line 55, column 1 Trigger.convertNumber...
 

 

I have nearly 4 years experience in SFDC specialized in visulforce,workflows,triggers,apex. I am available for freelancing SFDC support @ 20 hrs/week. I am located in Chennai,India. For any SFDC requirement, please let me know or contact me at  rashmi.nar@gmail.com

 

 

Regards,

Rashmi

I am interested in pursuing my career in Salesforce apps development. I have been exlporing/learning it myself. I would like to participate in a real life project while learning. Can anyone help me with this or point me in the right direction to find such an opportunity.

 

I have 6 years of experience in Siebel Applications development and 5 years in ASP.Net and C#.

 

Please contact me at abhat303@gmail.com.

 

Thanks much!