function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VRKVRK 

lookup field Issue

Hi experts..
pls find below my requirement scenario :
i have custom object (test_custObj) and  fileds  are ( age,street city, phone,email and contact_lookup( contact lookup field) ).  i already maintaed lookup relationship between custom object and contact .
Thrid party system sending details based on Contact ......i can able to store all the fields but not contact_lookup field . 
for example :
my third party sending details like   '23',' YG colony',' Hyd','88888888','abc@gmail.com'  and ' AMAR'.
i can able to store all the values expect 'AMAR' ( contact_lookup)
can some one help me how can i save/store  contact_lookup filed in custom object ?  
its urgent one ....thanks 


 
Best Answer chosen by VRK
balaji Jayararmanbalaji Jayararman
Hi sekar,
1. if the contact record exist in your system, you have to query the record using filters(Name or email) and then populate the contact record id to the IVR_Journey__c filed.

2. If the contact record does not exist, the create account and contact record using datas received from thirparty system and then populate the contact record id to the IVR_Journey__c filed.
 
global class IVRObjWebservice
{
webservice static Id createIVRRecord(String CallerID, String ContactChannel,String ContactIntent,String AuthenticationResult,
                                         String AutomatedTaskCompleted,String dob,String DNIS,String enddate,
                                         String LanguagePreference,String SeqMemberID,String SSN,String startdate,
                                         String subscriberId,String SubscriberPlanID,String SubscriberType,String SurveyOption,
                                         String TransferedTo,String ccChannelDuration,String ivrjourney)
    {
IVR_Journey__c con = new IVR_Journey__c();
con.Caller_ID__c = Integer.valueOf(CallerID);         
con.Authentication_Result__c = AuthenticationResult;
con.Automated_Task_Completed__c = AutomatedTaskCompleted;
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
con.Contact_Intent__c = ContactIntent;
con.DNIS__c = Integer.valueOf(DNIS);        
con.Language_Preference__c = LanguagePreference;
con.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);        
con.SSN__c = Integer.valueOf(SSN);       
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate);        
con.Date_of_Birth__c = Date.valueOf(dob);
con.Subscriber_ID_Numeric__c = Integer.valueOf(subscriberId);        
con.Subscriber_Plan_ID__c = SubscriberPlanID;
con.Subscriber_Type__c = SubscriberType;
con.Survey_Option__c = SurveyOption;
con.Transfered_To__c = TransferedTo;
Contact cnt;
try {
    //Query if contact exist in the system using filters
     cnt = [SELECT Id from Contact WHERE Name = :'contact_Name_from_thirdparty' 
      OR Email =:'Email from thirpaty' LIMIT 1 ];
} catch(Exception e) {
       //Create Account & contact record using datas received from the third party 
         system,if contact record does not exist.
       Account acc = new Account();   
        acc.name = 'Test Account';
        acc.BillingStreet='Test Street';
        acc.BillingCity='Test City';
        acc.BillingState='TEest';
        acc.BillingCountry='USA';
        acc.BillingPostalCode='33442';
        insert acc;        
        cnt = new Contact();
        cnt .FirstName = 'Test';
        cnt .LastName = 'Contact';
        cnt .Email = 'testcontact@gmail.com';
        cnt .Account = acc.Id;
        insert cont;
    }
con.IVR_Journey__c = cont.Id;  
       
insert con;
return con.id;
} 
   
}
I hope this solves your problems.

Please mark as best answer if it helps.

Thanks,
Balaji J
 

All Answers

hemanth ramakahemanth ramaka
Hii,
I created one custom object and give relation with contact it is saved...
Exactly tell me your problem
VRKVRK
Hi My requirements is pass through soap API. Not directly create contact I created wsdl file and able to pass all the field except conact_lookup. Thanks
balaji Jayararmanbalaji Jayararman
Hi,
can you provide your wsdl file? so that i can fix your problem.

Thanks,
Balaji J
VRKVRK
Hi Balaji,
Thanks for your response...
global class IVRObjWebservice
{
webservice static Id createIVRRecord(String CallerID, String ContactChannel,String ContactIntent,String AuthenticationResult,
                                         String AutomatedTaskCompleted,String dob,String DNIS,String enddate,
                                         String LanguagePreference,String SeqMemberID,String SSN,String startdate,
                                         String subscriberId,String SubscriberPlanID,String SubscriberType,String SurveyOption,
                                         String TransferedTo,String ccChannelDuration,String ivrjourney)
    {
IVR_Journey__c con = new IVR_Journey__c();
con.Caller_ID__c = Integer.valueOf(CallerID);         
con.Authentication_Result__c = AuthenticationResult;
con.Automated_Task_Completed__c = AutomatedTaskCompleted;
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
con.Contact_Intent__c = ContactIntent;
con.DNIS__c = Integer.valueOf(DNIS);        
con.Language_Preference__c = LanguagePreference;
con.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);        
con.SSN__c = Integer.valueOf(SSN);       
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate);        
con.Date_of_Birth__c = Date.valueOf(dob);
con.Subscriber_ID_Numeric__c = Integer.valueOf(subscriberId);        
con.Subscriber_Plan_ID__c = SubscriberPlanID;
con.Subscriber_Type__c = SubscriberType;
con.Survey_Option__c = SurveyOption;
con.Transfered_To__c = TransferedTo;

con.IVR_Journey__c = userinfo.getUserId();  
       
insert con;
return con.id;

   
}
Note :  IVR_Journey__c  is   Contact lookup Table between custom object and Contact.

i can able to store all the values expect IVR_Journey__c  is   Contact lookup  field.

Thanks for your time ...... sekhar
 
balaji Jayararmanbalaji Jayararman
Hi sekar,
1. if the contact record exist in your system, you have to query the record using filters(Name or email) and then populate the contact record id to the IVR_Journey__c filed.

2. If the contact record does not exist, the create account and contact record using datas received from thirparty system and then populate the contact record id to the IVR_Journey__c filed.
 
global class IVRObjWebservice
{
webservice static Id createIVRRecord(String CallerID, String ContactChannel,String ContactIntent,String AuthenticationResult,
                                         String AutomatedTaskCompleted,String dob,String DNIS,String enddate,
                                         String LanguagePreference,String SeqMemberID,String SSN,String startdate,
                                         String subscriberId,String SubscriberPlanID,String SubscriberType,String SurveyOption,
                                         String TransferedTo,String ccChannelDuration,String ivrjourney)
    {
IVR_Journey__c con = new IVR_Journey__c();
con.Caller_ID__c = Integer.valueOf(CallerID);         
con.Authentication_Result__c = AuthenticationResult;
con.Automated_Task_Completed__c = AutomatedTaskCompleted;
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
con.Contact_Intent__c = ContactIntent;
con.DNIS__c = Integer.valueOf(DNIS);        
con.Language_Preference__c = LanguagePreference;
con.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);        
con.SSN__c = Integer.valueOf(SSN);       
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate);        
con.Date_of_Birth__c = Date.valueOf(dob);
con.Subscriber_ID_Numeric__c = Integer.valueOf(subscriberId);        
con.Subscriber_Plan_ID__c = SubscriberPlanID;
con.Subscriber_Type__c = SubscriberType;
con.Survey_Option__c = SurveyOption;
con.Transfered_To__c = TransferedTo;
Contact cnt;
try {
    //Query if contact exist in the system using filters
     cnt = [SELECT Id from Contact WHERE Name = :'contact_Name_from_thirdparty' 
      OR Email =:'Email from thirpaty' LIMIT 1 ];
} catch(Exception e) {
       //Create Account & contact record using datas received from the third party 
         system,if contact record does not exist.
       Account acc = new Account();   
        acc.name = 'Test Account';
        acc.BillingStreet='Test Street';
        acc.BillingCity='Test City';
        acc.BillingState='TEest';
        acc.BillingCountry='USA';
        acc.BillingPostalCode='33442';
        insert acc;        
        cnt = new Contact();
        cnt .FirstName = 'Test';
        cnt .LastName = 'Contact';
        cnt .Email = 'testcontact@gmail.com';
        cnt .Account = acc.Id;
        insert cont;
    }
con.IVR_Journey__c = cont.Id;  
       
insert con;
return con.id;
} 
   
}
I hope this solves your problems.

Please mark as best answer if it helps.

Thanks,
Balaji J
 
This was selected as the best answer
VRKVRK
Hi  balaji Jayararman,
Thanks for very much for your help......................code is working and able to create contact through SOAP UI Tool....Thanks
 
VRKVRK
Hi Balaji,
i have one more small help on this........
How can i get Contact name based on Person Number(Person_Number__c) ?
User-added image
In the above screenshot,  john smith person number is 1.
How can get person number 1 for contact 'John Smith' in above ocde ?
do you have any idea on this? THanks

 
balaji Jayararmanbalaji Jayararman
Sekhar, Here is the query to get Contact Name based on Person Number
//There are two contact 'John Smith' with  Person_Number__c = 1, so i used list to store the two contacts. 
List<Contact> contList = [
				SELECT 
					Name
			 	FROM 
			 		Contact 
			 	WHERE 
			 		Person_Number__c = 1 
			 	ORDER BY 
			 		Person_Number__c ASC
			 ];
//Acess the first contact with Person_Number__c = 1
String contName = contList[0].Name;

If it does not help. Please elaborate your requirement in detail. 

Thanks,
Balaji J 
VRKVRK
Hi Balaji,
sorry for not update my requirement correctly......i will explain little bit clear now

User-added image
John smith person number is      1 
Sandra smith person number is    2
Angala smith person number is     3
Shama smith person number is    5.

Now , my requirement is  if i query  contact  'sandra smith'  (person number 2)  fetch result of  john smith (1).
                                        if i query contact 'Shama smith' (person number 5) will fetch result of John smith (1).
if Query contact persona number any ........results will fech peson number 1 contact name.

 i hope now you clear on requiremnet , pls let me know any idea on this ...
Thanks for your co-operation ..


 
balaji Jayararmanbalaji Jayararman
Sekar,

In the screeshot, 2 contacts are available with Person Number 1. which one is preferred contact? or you use any one from the 2 contacts.

If you want the preferred one, can you specify the additional filer parameters(ex: contact with maximum age - determined by Birthdate)?

Thanks,
Balaji J
VRKVRK
Hi Balaji
1 contact are available with person number 1  ONLY  not 2.

cnt = [SELECT Id from Contact WHERE (Name = :'Sandra Smith')
       AND (Person_Number__c = '1')  LIMIT 1 ];
i tried this query, but here its not returning  John smith  its returning only Sandra smith.
i need query , even if you filter by 'Sandra smith'(person number 2) result will display John smithh (person number 1)
Thanks in advace..... sekhar