• Vishwanath A
  • NEWBIE
  • 0 Points
  • Member since 2012

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

Hi,

 

is it poosible to take 

 

decimal.pow(decimal)

for ex: 12.34.pow(0.12);

 

Hi,

 

i have a code for converting number to word when im going to save the trigger it show 'Eding position out of bound ' error please help me on this issue

public static String convert(Decimal num) {
  
    // 0 to 999 999 999 999
    if (num == 0) { return 'zero'; }
   Integer ii=Integer.valueof(num);
    String snumber = String.valueof(ii);
  System.debug('llllllllllllllllll'+snumber);
    // pad with "0"
    String mask = '000000000000';
    Decimal df =Decimal.valueof(mask);
   //snumber = num.format();

    // XXXnnnnnnnnn 

    Integer billions = Integer.valueof(snumber.substring(0,3));
    System.debug('bbbbbbbbbbb'+billions );
    // nnnXXXnnnnnn
    integer millions  = Integer.valueof(snumber.substring(3,6)); 
        System.debug('mmmmmmmm'+millions  );
    // nnnnnnXXXnnn
    integer hundredThousands = Integer.valueof(snumber.substring(6,9)); 
        System.debug('hhhhhhhhh'+hundredThousands );
    // nnnnnnnnnXXX
    integer thousands = Integer.valueof(snumber.substring(9,12));    
        System.debug('tttttttttt'+thousands );

 

Hi all,

I have written a Trigger but i am not able to write testclass and tried different ways plz help me out...

 

This trigger works as roll-up summary 

trigger TotalQtyShippedInsaleorderitem on Dispatch_Detail_Item__c (after delete, after insert, after undelete, 
after update) {
  Map<Id,Sale_Order_Item__c> mapsoi = new Map<Id,Sale_Order_Item__c>();
    Set<Id> soiId = new Set<Id>();
    try {
        // If insert, update or undelete put the new values into soiId
        if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete){
            for(Dispatch_Detail_Item__c ddi : Trigger.new) {
                soiId.add(ddi.Sale_Order_Item__c);
            }
        }
        // If we are updating, some Sale_Order_Item__c values might change, so include that as well as deletes
        if(Trigger.isUpdate || Trigger.isDelete){
            for(Dispatch_Detail_Item__c ddi : Trigger.old) {
                soiId.add(ddi.Sale_Order_Item__c);
            }
        }
        
        soiId.remove(null);
        for(Id pId : soiId) {
            mapsoi.put(pId,new Sale_Order_Item__c(Id=pId,Total_Of_Dispatches_Shipped__c=0));
        }
        
        for(Dispatch_Detail_Item__c ddi : [select Total_Amt_Shipped__c,Sale_Order_Item__c from Dispatch_Detail_Item__c WHERE Sale_Order_Item__c IN: soiId]) {
            mapsoi.get(ddi.Sale_Order_Item__c).Total_Of_Dispatches_Shipped__c += ddi.Total_Amt_Shipped__c;
        }
        
        update mapsoi.values();
    }
    catch(Exception e) {
        System.debug('### Exception: ' + e.getMessage());
    }

}

 Here is the Testclass, There are two objects "Sale order item" and" Dispatch detail item" but the problem is"sale order item" is related to "sale order" object and i have some mandatory lookups and master detail fields like DEALER ACCOUNT master detail to ACCOUNT , CUSTOMER ACCOUNT lookup to ACCOUNT and OPPORTUNITY lookup . How can i call this id's.

@istest
private class TotalShippedTestClass {
    static testMethod void myUnitTest() { 
        Sale_Order_Item__c soi = new Sale_Order_Item__c(Sale_Order__c='a0KO000000096Wl');
        Dispatch_Detail_Item__c ddi = new Dispatch_Detail_Item__c(Sale_Order_Item__c=soi.id);
        insert soi;
        insert ddi;
        update soi;
        update ddi;
    }
}

 

  • March 12, 2012
  • Like
  • 0