• Prateek Garg
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
trigger stockupdate on Line_Item2__c (before insert,before update) {
List<Stock__c> sto= new List<Stock__c>();
    if(trigger.isinsert){
for(Line_Item2__c li:trigger.new){
sto.add(new Stock__c(Name=li.Product_Code__c,Product_Name__c=li.Product_Name__c,Manufacturing_Date__c=li.Manufacturing_Date__c,Batch_No__c=li.name,Expiry_Date__c=li.Expiry_Date__c,No_Of_Boxes__c=li.No_Of_Boxes__c,Pieces_Per_Box__c=li.Pieces_Per_Box__c,Manufacturer_Name__c=li.Manufacturer_Name__c,Total_No_Of_Pieces__c=li.Total_No_Of_Pieces__c)) ;           
                                  }
        insert sto;  
    }
     if(trigger.isupdate){
        for(Line_Item2__c lt:trigger.new){
            stock__c st;  
            st.Name=lt.Product_Code__c;
            st.Product_Name__c=lt.Product_Name__c;
            st.Manufacturing_Date__c=lt.Manufacturing_Date__c;
            st.Batch_No__c=lt.name;
            st.Expiry_Date__c=lt.Expiry_Date__c;
            st.No_Of_Boxes__c=lt.No_Of_Boxes__c;
            st.Pieces_Per_Box__c=lt.Pieces_Per_Box__c;
            st.Manufacturer_Name__c=lt.Manufacturer_Name__c;
            st.Total_No_Of_Pieces__c=lt.Total_No_Of_Pieces__c;
            sto.add(st);
            
            
        }
   upsert sto;
     }
}

Thanks in advance
User-added image
when i am clicking on product name it is working properly as a link. but when i try to click on batch no.in my lookup it is not working as link.so how can i achieve that.pls Help.
Hello friends.   I have a query. I have two object both are unrelated name stock__c(fields:- product name,total no.of pieces) and line_item__c (fields:-product name,unit sold). what i want is i want to apply trigger on these unrelated object.and want to update total no of pieces by subtracting it by unit sold value.
Thanks in advance
trigger stockupdate on Line_Item2__c (before insert,before update) {
List<Stock__c> sto= new List<Stock__c>();
    if(trigger.isinsert){
for(Line_Item2__c li:trigger.new){
sto.add(new Stock__c(Name=li.Product_Code__c,Product_Name__c=li.Product_Name__c,Manufacturing_Date__c=li.Manufacturing_Date__c,Batch_No__c=li.name,Expiry_Date__c=li.Expiry_Date__c,No_Of_Boxes__c=li.No_Of_Boxes__c,Pieces_Per_Box__c=li.Pieces_Per_Box__c,Manufacturer_Name__c=li.Manufacturer_Name__c,Total_No_Of_Pieces__c=li.Total_No_Of_Pieces__c)) ;           
                                  }
        insert sto;  
    }
     if(trigger.isupdate){
        for(Line_Item2__c lt:trigger.new){
            stock__c st;  
            st.Name=lt.Product_Code__c;
            st.Product_Name__c=lt.Product_Name__c;
            st.Manufacturing_Date__c=lt.Manufacturing_Date__c;
            st.Batch_No__c=lt.name;
            st.Expiry_Date__c=lt.Expiry_Date__c;
            st.No_Of_Boxes__c=lt.No_Of_Boxes__c;
            st.Pieces_Per_Box__c=lt.Pieces_Per_Box__c;
            st.Manufacturer_Name__c=lt.Manufacturer_Name__c;
            st.Total_No_Of_Pieces__c=lt.Total_No_Of_Pieces__c;
            sto.add(st);
            
            
        }
   upsert sto;
     }
}

Thanks in advance
User-added image
when i am clicking on product name it is working properly as a link. but when i try to click on batch no.in my lookup it is not working as link.so how can i achieve that.pls Help.
I'm bit confused with this terms, when should I go for list<sobject> and when for sobject only? Can you please explain when to use list<list<set>>?