+ Start a Discussion
force shahidforce shahid 

Updation Error in Contact Object while updating record through custom object

Hi Friends,

I have a problem on updation [rpcess. I am updating contact records through custom object. And I write a method for updation. If the custom object field is empty then no need to update contact field. 
But this scenario is different in  MQL_Date field. If MQL_Date field is having a value in contact object then no need to update this field with custom object MQL_date field.
But its not working. 
The MQL_Date field of contact object is updated with custom object MQL_Date field field.

My Code is :

c1.Became_an_MQL_Lead_Date__c = isValidInputDate( c1.Became_an_MQL_Lead_Date__c)? c1.Became_an_MQL_Lead_Date__c : customObjRecord.MQL_Date__c;

Method is : 

 public static boolean isValidInputDate(Datetime D) {
        if(D != null ) {
            return true;
        return false;

Thanks in Advance,

Try this :

c1.Became_an_MQL_Lead_Date__c = NOT(ISBLANK( c1.Became_an_MQL_Lead_Date__c))? customObjRecord.MQL_Date__c : c1.Became_an_MQL_Lead_Date__c ;

No need of method "isValidInputDate"
Try this :
public static void updateContact(Contact c1, Campaign_Entry__c customObjRecord, String sourceCampaignId) {

		C1 != null && 
		customObjRecord != null && 
		customObjRecord.MQL_Date__c != null && 
		C1.Became_an_MQL_Lead_Date__c == null
		c1.Became_an_MQL_Lead_Date__c = customObjRecord.MQL_Date__c;

But which record of child obejct throws a value in parent?
I mean you mentioned "The MQL_Date field of contact object is updated with custom object MQL_Date field field." What happens when Contact has 5 child records and they all have different MQL_Date field on each. Which one should mirror the Contact's MQL_Date field?