• Jyothy Kiran
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi , 

I am getting an error when trying to deploy a class to production.

The error is on line 10 of the trigger

Please find the trigger posted here.

This is the Trigger
trigger OTC_TrgPopulateKeyContactDetails on Contract (before insert,before update) {

    List<Id> accountIds = new List<Id>(); 
    List<Id> contactIds = new List<Id>();
    for(Contract cont : Trigger.New){
        accountIds.add(cont.AccountId);
        if(cont.Key_Contact__c != null)
            contactIds.add(cont.Key_Contact__c);
    }
    Map<Id,Account> accMap = new Map<Id,Account>([Select Id,Name,PersonEmail,Passport__pc,OTC_E_ID_Upload__pc,PersonMobilePhone,Phone,IsPersonAccount,FirstName,LastName,(Select Id,Email,MobilePhone,FirstName,LastName,Phone,Passport__c,OTC_E_ID_Upload__c from Contacts where OTC_Key_Contact__c = true) from Account where Id = :accountIds]);
    Map<Id,Contact> conMap = new Map<Id,Contact>();
    if(contactIds.size() > 0) conMap = new Map<Id,Contact>([Select Id,Email,MobilePhone,FirstName,LastName,Phone,Passport__c,OTC_E_ID_Upload__c from Contact where Id = :contactIds]);
    
    for(Contract cont : Trigger.New){
        if(cont.Key_Contact__c != null && conMap.containsKey(cont.Key_Contact__c)){
            Contact con = conMap.get(cont.Key_Contact__c);
            cont.KeyContact_Email_id__c = con.Email;
            cont.KeyContact_MobileNumber__c = con.MobilePhone;
            cont.OTC_Key_Contact_Name__c = con.FirstName == null ? con.LastName : con.FirstName+' '+con.LastName;
            cont.KeyContact_Office__c = con.Phone;
            cont.E_ID_only_for_Jobs__c = con.OTC_E_ID_Upload__c;
            cont.OTC_Passport_Copy_Person_Signing_Cheque__c = con.Passport__c; 
        } else{
            if(accMap.get(cont.AccountId).IsPersonAccount == true){
                cont.KeyContact_Email_id__c = accMap.get(cont.AccountId).PersonEmail;
                cont.KeyContact_MobileNumber__c = accMap.get(cont.AccountId).PersonMobilePhone; 
                cont.OTC_Key_Contact_Name__c = accMap.get(cont.AccountId).Name;
                cont.KeyContact_Office__c = accMap.get(cont.AccountId).Phone;
                cont.OTC_Passport_Copy_Person_Signing_Cheque__c = accMap.get(cont.AccountId).Passport__pc;
                cont.E_ID_only_for_Jobs__c = accMap.get(cont.AccountId).OTC_E_ID_Upload__pc;
            }else if(accMap.get(cont.AccountId).Contacts.size()>0){
                cont.KeyContact_Email_id__c = accMap.get(cont.AccountId).Contacts[0].Email;
                cont.KeyContact_MobileNumber__c = accMap.get(cont.AccountId).Contacts[0].MobilePhone;
                cont.OTC_Key_Contact_Name__c = accMap.get(cont.AccountId).Contacts[0].FirstName == null ? accMap.get(cont.AccountId).Contacts[0].LastName : accMap.get(cont.AccountId).Contacts[0].FirstName+' '+accMap.get(cont.AccountId).Contacts[0].LastName;
                cont.KeyContact_Office__c = accMap.get(cont.AccountId).Contacts[0].Phone;
                cont.E_ID_only_for_Jobs__c = accMap.get(cont.AccountId).Contacts[0].OTC_E_ID_Upload__c;
                cont.OTC_Passport_Copy_Person_Signing_Cheque__c = accMap.get(cont.AccountId).Contacts[0].Passport__c;
            }
        }
    }

}
I have posted the class as a reply

Thanks
I have a variable 'd' that captures the current date time.
In the same page i have a button inside jquery which is redirecting to a new page in new window.
I want to pass the variable d  in the url.
Code:
var d = new Date();
The url is :   '<a href="/apex/vfp_KOT?oid=" class="js-newWindow" data-popup="width=500,height=600"><button type="button" class="btn btn-primary">Print KOT</button></a>&nbsp;&nbsp;&nbsp;&nbsp;'+

New Window :  
$(document).ready(function(){
            $('.js-newWindow').click(function (event) {
                event.preventDefault();
                var $this = $(this);
                var url = $this.attr("href");
                var windowName = "popUp";
                var windowSize = $this.data("popup");
                //alert($.session.get('sessionoid'));
                var noid = $.session.get('sessionoid');
                var urlnew = url+noid;
                window.open(urlnew, windowName, windowSize);
            });
        });
  • August 09, 2017
  • Like
  • 0
I have written a try catch block but dont know how to unit test it .Below is the code .

try{
        Schema.SObjectField extField = Order.Fields.id__c;
        List<Database.upsertResult> listOfResults = Database.upsert(listOfOrder,extField,false);

    }
    catch(Exception e)
    {
        for(Order listOrder: listOfOrder)
        {
         Error_Log__c error = new  Error_Log__c();
         System.debug('Error'+e);
         }
    }

Please help me to see if my upsert works fine or not in this logic.
Hi , 

I am getting an error when trying to deploy a class to production.

The error is on line 10 of the trigger

Please find the trigger posted here.

This is the Trigger
trigger OTC_TrgPopulateKeyContactDetails on Contract (before insert,before update) {

    List<Id> accountIds = new List<Id>(); 
    List<Id> contactIds = new List<Id>();
    for(Contract cont : Trigger.New){
        accountIds.add(cont.AccountId);
        if(cont.Key_Contact__c != null)
            contactIds.add(cont.Key_Contact__c);
    }
    Map<Id,Account> accMap = new Map<Id,Account>([Select Id,Name,PersonEmail,Passport__pc,OTC_E_ID_Upload__pc,PersonMobilePhone,Phone,IsPersonAccount,FirstName,LastName,(Select Id,Email,MobilePhone,FirstName,LastName,Phone,Passport__c,OTC_E_ID_Upload__c from Contacts where OTC_Key_Contact__c = true) from Account where Id = :accountIds]);
    Map<Id,Contact> conMap = new Map<Id,Contact>();
    if(contactIds.size() > 0) conMap = new Map<Id,Contact>([Select Id,Email,MobilePhone,FirstName,LastName,Phone,Passport__c,OTC_E_ID_Upload__c from Contact where Id = :contactIds]);
    
    for(Contract cont : Trigger.New){
        if(cont.Key_Contact__c != null && conMap.containsKey(cont.Key_Contact__c)){
            Contact con = conMap.get(cont.Key_Contact__c);
            cont.KeyContact_Email_id__c = con.Email;
            cont.KeyContact_MobileNumber__c = con.MobilePhone;
            cont.OTC_Key_Contact_Name__c = con.FirstName == null ? con.LastName : con.FirstName+' '+con.LastName;
            cont.KeyContact_Office__c = con.Phone;
            cont.E_ID_only_for_Jobs__c = con.OTC_E_ID_Upload__c;
            cont.OTC_Passport_Copy_Person_Signing_Cheque__c = con.Passport__c; 
        } else{
            if(accMap.get(cont.AccountId).IsPersonAccount == true){
                cont.KeyContact_Email_id__c = accMap.get(cont.AccountId).PersonEmail;
                cont.KeyContact_MobileNumber__c = accMap.get(cont.AccountId).PersonMobilePhone; 
                cont.OTC_Key_Contact_Name__c = accMap.get(cont.AccountId).Name;
                cont.KeyContact_Office__c = accMap.get(cont.AccountId).Phone;
                cont.OTC_Passport_Copy_Person_Signing_Cheque__c = accMap.get(cont.AccountId).Passport__pc;
                cont.E_ID_only_for_Jobs__c = accMap.get(cont.AccountId).OTC_E_ID_Upload__pc;
            }else if(accMap.get(cont.AccountId).Contacts.size()>0){
                cont.KeyContact_Email_id__c = accMap.get(cont.AccountId).Contacts[0].Email;
                cont.KeyContact_MobileNumber__c = accMap.get(cont.AccountId).Contacts[0].MobilePhone;
                cont.OTC_Key_Contact_Name__c = accMap.get(cont.AccountId).Contacts[0].FirstName == null ? accMap.get(cont.AccountId).Contacts[0].LastName : accMap.get(cont.AccountId).Contacts[0].FirstName+' '+accMap.get(cont.AccountId).Contacts[0].LastName;
                cont.KeyContact_Office__c = accMap.get(cont.AccountId).Contacts[0].Phone;
                cont.E_ID_only_for_Jobs__c = accMap.get(cont.AccountId).Contacts[0].OTC_E_ID_Upload__c;
                cont.OTC_Passport_Copy_Person_Signing_Cheque__c = accMap.get(cont.AccountId).Contacts[0].Passport__c;
            }
        }
    }

}
I have posted the class as a reply

Thanks
Public virtual class  Parent9 {
    public  void M1(){
   system.debug('hello parent');
    }
}
 Public class Child9 extends Parent9(){
        public override void M1(){
        system.debug('hello child'); 
            }
 }
Salesforce.com could not email the report to any of the specified recipients. Check that recipients are specified and that they have the appropriate permissions to view the report.

If you get this ^error:

Make sure you also check:
Setup > Customize > Reports & Dashboards > Email Notifications > Allow Reports and Dashboards to Be Sent to Portal Users

Posting this here since it took me a long time to find this checkbox.
 
Iam new to customization, I want to know In  which situation we can go with List,set and map.
 
Hi all,

        I have a custom object?(card)  in salesforce with field (service order) . I would like to get information from oracle db that match this service order.

What approach would be better?
What about service calls?
I am baby on this case of integration?
Can anybody help me?
If i do REST api,
i have some questions.
I could find a blog :-
https://developer.salesforce.com/blogs/developer-relations/2013/08/integrating-force-com-using-xml-in-apex.html
Can i do something like this?
1. When the call is made to the XML server, is the web browser on the user's PC making the call or is the SalesForce.com server making the call?  
2. Is it makes a difference in how we will need to navigate around the firewall issue?
3. Which is good to use SOAP / REST?
4. What is difference between them?

 Thanks in advance.