• CarlosLima
  • NEWBIE
  • 30 Points
  • Member since 2015

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

I have a trigger below that is partially updating the record, may anyone assist me in figuring out what is causing the second update to Fail. 

It updates Ship_From_Zone1__c  and Hub_Ship_From_Zone__c  but not the shipto and the hubshipto Ids
trigger PopulateRegion on Shipment_Order__c (before insert, before update) {


for(Shipment_Order__c shipmentorder : Trigger.new) {

List<Ship_To__c> shipto= new List<Ship_To__c>();  
shipto = [Select Id from Ship_To__c WHERE Ship_To__c.Ship_From_Zone__c = :shipmentorder.Ship_From_Zone1__c  AND Ship_To__c.Name =:shipmentorder.Ship_From_Country__c ORDER BY Id LIMIT 1];
List<Ship_To__c> hubshipto = new List<Ship_To__c>(); 
hubshipto = [Select Id from Ship_To__c WHERE Ship_To__c.Ship_From_Zone__c = :shipmentorder.Hub_Ship_From_Zone__c AND Ship_To__c.Name =:shipmentorder.Hub_Country__c ORDER BY Id LIMIT 1];
    
If(shipmentorder.Hub_Shipment_Formula__c == False && shipmentorder.Ship_From_Country__c != null && shipto.size() > 0 ){


        string region = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c;
        shipmentorder.Ship_From_Zone1__c = region; 
        shipmentorder.Ship_to__c = shipto[0].Id;
}
    
  
    
    If(shipmentorder.Hub_Shipment_Formula__c == True && shipmentorder.Hub_Country__c != null && shipto.size() > 0)  { 
    
     
    string region = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c;
    string hubregion = Country_Region_List__c.getInstance(shipmentorder.Hub_Country__c).Region__c;
   
      shipmentorder.Ship_From_Zone1__c = region; 
      shipmentorder.Hub_Ship_From_Zone__c = hubregion; 
      shipmentorder.Ship_to__c = hubshipto[0].Id ;
      shipmentorder.From_Hub_Destination__c = shipto[0].Id ;

}

}

}


 
Hello everyone, i'm trying to open a subtab on service cloud but im facing the issue that the url does not exist. Below the code:
HYPERLINK("javascript&colon:if(typeof(srcUp)=='function') {srcUp('/" & Id & "?isdtp=vw');}"+ " else {window.location.href='/" & Id & "?isdtp=vw'}", myObj_field__c, "_parent" )

also, if i change to "_self" nothing happen. 

Thanks in advance
 

Hi All,

while updating a particular field of an object for a single record by mistake I updated that field for all the records present for that object. I want my field to have old values restored. there is no history tracking for that object. can we do it through trigger or class. 
kindly help its urgent.

Thanks
 
Hi,

As I have two maps 
Map 1---Program code and ContactId
Map 2---Program Code and Program term.


Now how to get the count of uniques program code from these two map.

Any idea.
Hello Guys

I have a trigger below that is partially updating the record, may anyone assist me in figuring out what is causing the second update to Fail. 

It updates Ship_From_Zone1__c  and Hub_Ship_From_Zone__c  but not the shipto and the hubshipto Ids
trigger PopulateRegion on Shipment_Order__c (before insert, before update) {


for(Shipment_Order__c shipmentorder : Trigger.new) {

List<Ship_To__c> shipto= new List<Ship_To__c>();  
shipto = [Select Id from Ship_To__c WHERE Ship_To__c.Ship_From_Zone__c = :shipmentorder.Ship_From_Zone1__c  AND Ship_To__c.Name =:shipmentorder.Ship_From_Country__c ORDER BY Id LIMIT 1];
List<Ship_To__c> hubshipto = new List<Ship_To__c>(); 
hubshipto = [Select Id from Ship_To__c WHERE Ship_To__c.Ship_From_Zone__c = :shipmentorder.Hub_Ship_From_Zone__c AND Ship_To__c.Name =:shipmentorder.Hub_Country__c ORDER BY Id LIMIT 1];
    
If(shipmentorder.Hub_Shipment_Formula__c == False && shipmentorder.Ship_From_Country__c != null && shipto.size() > 0 ){


        string region = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c;
        shipmentorder.Ship_From_Zone1__c = region; 
        shipmentorder.Ship_to__c = shipto[0].Id;
}
    
  
    
    If(shipmentorder.Hub_Shipment_Formula__c == True && shipmentorder.Hub_Country__c != null && shipto.size() > 0)  { 
    
     
    string region = Country_Region_List__c.getInstance(shipmentorder.Ship_From_Country__c).Region__c;
    string hubregion = Country_Region_List__c.getInstance(shipmentorder.Hub_Country__c).Region__c;
   
      shipmentorder.Ship_From_Zone1__c = region; 
      shipmentorder.Hub_Ship_From_Zone__c = hubregion; 
      shipmentorder.Ship_to__c = hubshipto[0].Id ;
      shipmentorder.From_Hub_Destination__c = shipto[0].Id ;

}

}

}


 
For example, we have a custom object called "Internal Task" which is related to the Case object through a lookup field.
What I would like to setup is 
A Case can only be closed, if the following is True:
All related Stories are in a status of "Delivered", "completed
How to write trigger for this.