• Alex Raine 9
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi All,

I was wondering if anyone would be able to assist me with the below:

I have a custom object called Emergecny Stock Order which has a child object called Emergecny Stock Order Lines that has a field called Product

I need to use apex code to group all the order lines related to the same emergency stock order by Product. I then need to be able to identify how many records are within each group (i.e how many order lines have the same product and are related to the same emergency stock order). This is so i cna perform a particular action if a group contians more than 1 record.

Regards
Hi,

I'm new to creating apex triggers and so was looking to see if anyone could assist with the below problem:

I have an object called Warehouse Picking (Warehouse_Picking__c) which has a lookup to an object called Location (SVMXC__Site__c) via a field called "Engineer Location" (SVMX_Engineer_Location__c). I need to be able to update the field "Count of In Progress Warehouse Picks" (Count_of_In_Progress_Warehouse_Picks__c) on the related location record whenever a Warehouse Picking record with a "Status" (Status__c) is deleted. The field being updated is a number field and the trigger needs to reduce its value by 1.

I have included the trigger i have created so far below and whilst it does not contain the condition of the warehouse pick record's status i have tested it as is but get the following error:

System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateVanLocationwhenWarehousePickdeleted: line 18, column 1

Please can you therfore assisit with:

1) rectifying the trigger so that the above error no longer occurs
2) modifying the trigger to include the condition that the Location record is only updated when an "In Progress" warehouse picking record is deleted
 
trigger UpdateVanLocationwhenWarehousePickdeleted on Warehouse_Picking__c (after delete) {

   List<Id> idSiteList = new List<Id>();
   List<SVMXC__Site__c> siteListToUpdate = new List<SVMXC__Site__c>();
  
    {    
        for (Warehouse_Picking__c wp : trigger.old) {
                     
            idSiteList.add(wp.SVMX_Engineer_Location__c);
 }   
}

if(idSiteList.isEmpty()) return;

for(Id id : idSiteList) {

    SVMXC__Site__c site = new SVMXC__Site__c(Id = id); 
    site.Count_of_In_Progress_Warehouse_Picks__c= site.Count_of_In_Progress_Warehouse_Picks__c - 1;
    
    siteListToUpdate.add(site);
    
}

if(siteListToUpdate.size() > 0)
Database.update(siteListToUpdate);
}

Thank you in advance for any assistance you can render.
Hi,

I'm new to creating apex triggers and so was looking to see if anyone could assist with the below problem:

I have an object called Warehouse Picking (Warehouse_Picking__c) which has a lookup to an object called Location (SVMXC__Site__c) via a field called "Engineer Location" (SVMX_Engineer_Location__c). I need to be able to update the field "Count of In Progress Warehouse Picks" (Count_of_In_Progress_Warehouse_Picks__c) on the related location record whenever a Warehouse Picking record with a "Status" (Status__c) is deleted. The field being updated is a number field and the trigger needs to reduce its value by 1.

I have included the trigger i have created so far below and whilst it does not contain the condition of the warehouse pick record's status i have tested it as is but get the following error:

System.NullPointerException: Attempt to de-reference a null object: Trigger.UpdateVanLocationwhenWarehousePickdeleted: line 18, column 1

Please can you therfore assisit with:

1) rectifying the trigger so that the above error no longer occurs
2) modifying the trigger to include the condition that the Location record is only updated when an "In Progress" warehouse picking record is deleted
 
trigger UpdateVanLocationwhenWarehousePickdeleted on Warehouse_Picking__c (after delete) {

   List<Id> idSiteList = new List<Id>();
   List<SVMXC__Site__c> siteListToUpdate = new List<SVMXC__Site__c>();
  
    {    
        for (Warehouse_Picking__c wp : trigger.old) {
                     
            idSiteList.add(wp.SVMX_Engineer_Location__c);
 }   
}

if(idSiteList.isEmpty()) return;

for(Id id : idSiteList) {

    SVMXC__Site__c site = new SVMXC__Site__c(Id = id); 
    site.Count_of_In_Progress_Warehouse_Picks__c= site.Count_of_In_Progress_Warehouse_Picks__c - 1;
    
    siteListToUpdate.add(site);
    
}

if(siteListToUpdate.size() > 0)
Database.update(siteListToUpdate);
}

Thank you in advance for any assistance you can render.