• Lakshmi Usha Ramabhotla
  • NEWBIE
  • 0 Points
  • Member since 2018

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

Can someone tell me the obvious and silly mistake I am making?

 

trigger GoItemfromAsset on SchedInt__c (before update) { if(Trigger.isUpdate) { for(SchedInt__c s : Trigger.new) { if (s.ItemFromAsset__c==true) { ItemfromAsset.createItemfromAsset(); } } }}

 

 

 

The class is as follows: 

 

 

public with sharing class ItemfromAsset {
    
    public static Map<id, Asset> getAssetToCreateItem() {
        
        DateTime dT = System.now();
        String myDate = dT.format('d');
        Decimal myDay = decimal.valueOf(myDate);
        
        List<Asset> asts =  [select id, name, AccountId, Billing_Product__c, Quantity 
                                from asset 
                                where Day__c = :myDay
                                and Status = 'Active'];
        Map<id, Asset> result = new Map<id, Asset>();
        for (Asset ast : asts) {
            result.put(ast.id, ast);
        }
        return result;
    }
    

    public static void createItemsfromAsset() {
        
        DateTime dT = System.now();
        String myDate = dT.format('d');
        Decimal myDay = decimal.valueOf(myDate);
        
        Map<id, Asset> AssetIdToItem = getAssetToCreateItem();
        system.debug('got AssetIdToItem map of size ' + AssetIdToItem.size());
        
        Map<id, Asset> idToAsset = new Map<id,Asset>();
        
        List<Item__c> Items = new List<Item__c>(); 
        
        List<Asset> assets = [select id, name, AccountId, Billing_Product__c, Quantity 
                                from asset 
                                where Day__c = :myDay 
                                and Status = 'Installed'];
        System.debug('***** accounts returned = ' + assets.size());
        
        insert items;
        
        Map<id,id> astToItem = new Map<id, id>();
        System.debug('***** about to iterate throught the items');
        
        for (Item__c currItem : items) {
            astToItem.put(currItem.asset__c, currItem.id);
            System.debug('***** accid/invid = ' + currItem.account__c + '/' + currItem.id);
        }
        }
        }

 

 

 

Message Edited by Ross James on 03-01-2010 07:54 PM
Message Edited by Ross James on 03-01-2010 07:55 PM