• SSeb
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
            
            OpportunityLineItem prod;
            prod =  [Select Quantity, productcode, Nav_Inventory__c  From OpportunityLineItem where Opp_Line_Item_Id__c =:oli.Opp_Line_Item_Id__c];
            
           prod.Old_Quantity__c= prod.Quantity;

           update prod;
  • January 14, 2020
  • Like
  • 0
trigger Product_Schedule on OpportunityLineItem (after update,after insert) 
{
    for ( OpportunityLineItem o : Trigger.new)
    { 
        Opportunity opps;
        // id OppLineItemID = o.Opp_Line_Item_Id__c ;
        id OppLineItemID = o.ID ;
        system.debug('Opurtunity line item triggered ' + o.Opp_Line_Item_Id__c  + 'Opportunity ID ' + o.ID);
        
        opps =  [Select  o.First_Ship_Date__c  ,o.Expected_Return_Ship_Date__c, o.Min_K_QPID__c,
                 (Select Quantity, productcode  From OpportunityLineItems where ProductCode = 'K-QPID') From Opportunity o 
                 Where id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Quantity > 0 and id =:o.id) ];
        
        OpportunityLineItem prod;
        prod =  [Select Quantity, productcode, Nav_Inventory__c  From OpportunityLineItem where Opp_Line_Item_Id__c =:o.Opp_Line_Item_Id__c];
        
        Datascan_Product_Availability__c Avail = [select K_QPID__c , Count_Date__c From Datascan_Product_Availability__c c 
                                                  where (c.Count_Date__c > :opps.First_Ship_Date__c) and (c.Count_Date__c < :opps.Expected_Return_Ship_Date__c) 
                                                  order by Count_Date__c asc limit 1 ];
        
        opps.Min_K_QPID__c  = Avail.K_QPID__c ;
        opps.Min_K_QPID_Date__c = Avail.Count_Date__c;
        update opps;
        
        //select MIN(K_DS_WIFI_1__c) From Datascan_Product_Availability__c where count_date__C > 2019-10-18 and count_date__c < 2019-11-22
        system.debug('opps ' + opps.First_Ship_Date__c + opps.Expected_Return_Ship_Date__c );
        system.debug('prod ' + prod.quantity + prod.productcode );
        system.debug('Avail ' + Avail.K_QPID__c  );
        
    }
}
  • October 30, 2019
  • Like
  • 0
Step 1 - Get ship date and return date from Opportunity -
select  o.Name, o.First_Ship_Date__c, o.Expected_Return_Ship_Date__c
from Opportunity o where id in ( select OpportunityId FROM OpportunityLineItem )

Step 2- Get the min ( count of product ) between the ship date and return date from my custom object where I have the product on hand by date.
Select MIN(K_DS_WIFI_1__c) from Datascan_Product__c where Count_Date__c > 2019-04-01 and Count_Date__c < 2019-04-30


Step3 : Use a trigget to update a field with the value of the min ( count of product)  on the Opportunity line item.

Questions
Is there a way to combine step 1 and step 2 in the same soql.
How to call the soql in the trigger?
 
  • September 16, 2019
  • Like
  • 0
            
            OpportunityLineItem prod;
            prod =  [Select Quantity, productcode, Nav_Inventory__c  From OpportunityLineItem where Opp_Line_Item_Id__c =:oli.Opp_Line_Item_Id__c];
            
           prod.Old_Quantity__c= prod.Quantity;

           update prod;
  • January 14, 2020
  • Like
  • 0
trigger Product_Schedule on OpportunityLineItem (after update,after insert) 
{
    for ( OpportunityLineItem o : Trigger.new)
    { 
        Opportunity opps;
        // id OppLineItemID = o.Opp_Line_Item_Id__c ;
        id OppLineItemID = o.ID ;
        system.debug('Opurtunity line item triggered ' + o.Opp_Line_Item_Id__c  + 'Opportunity ID ' + o.ID);
        
        opps =  [Select  o.First_Ship_Date__c  ,o.Expected_Return_Ship_Date__c, o.Min_K_QPID__c,
                 (Select Quantity, productcode  From OpportunityLineItems where ProductCode = 'K-QPID') From Opportunity o 
                 Where id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Quantity > 0 and id =:o.id) ];
        
        OpportunityLineItem prod;
        prod =  [Select Quantity, productcode, Nav_Inventory__c  From OpportunityLineItem where Opp_Line_Item_Id__c =:o.Opp_Line_Item_Id__c];
        
        Datascan_Product_Availability__c Avail = [select K_QPID__c , Count_Date__c From Datascan_Product_Availability__c c 
                                                  where (c.Count_Date__c > :opps.First_Ship_Date__c) and (c.Count_Date__c < :opps.Expected_Return_Ship_Date__c) 
                                                  order by Count_Date__c asc limit 1 ];
        
        opps.Min_K_QPID__c  = Avail.K_QPID__c ;
        opps.Min_K_QPID_Date__c = Avail.Count_Date__c;
        update opps;
        
        //select MIN(K_DS_WIFI_1__c) From Datascan_Product_Availability__c where count_date__C > 2019-10-18 and count_date__c < 2019-11-22
        system.debug('opps ' + opps.First_Ship_Date__c + opps.Expected_Return_Ship_Date__c );
        system.debug('prod ' + prod.quantity + prod.productcode );
        system.debug('Avail ' + Avail.K_QPID__c  );
        
    }
}
  • October 30, 2019
  • Like
  • 0