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 

How to pass contact lookup filed value..

Hi folks,
can someone help on how to pass contact Lookup filed value through webservicies......
i can able to pass all the values except  Lookup field contact value based on personal number .
can some one please check and let me know how can i pass lookup field value based on personal number .....Thanks
please see below code and result screenshot...
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.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);  
con.DNIS__c = Integer.valueOf(DNIS);
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate); 
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
Contact contact = new Contact (Id = con.Ivr_Journey__c);      ( i think this line code is wrong)
insert con;
return con.id;


}
User-added image
i created correctly lookup relation ship between contact and custom object(IVR_journey_c) .....
User-added image

 
Best Answer chosen by VRK
tonante27tonante27
Sekar:  First you need to pass into the webservce an ID Parameter type for the contact Id (test1---.. etc).. I call it ContactId.
Test1 contact only neds to send its Id as parameter list not the full contact.
Then you need to assign that ID to the Contact Id parameter  to  con.Ivr_Journey__c.  Here is what I mean:
 
global class IVRObjWebservice
{
    webservice static Id createIVRRecord(String CallerID, String ContactChannel,String ContactIntent,String AuthenticationResult,Id ContactId <------ Id of Contact
                                         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.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);  
con.DNIS__c = Integer.valueOf(DNIS);
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate); 
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
con.Ivr_Journey__c = ContactId;
insert con;
return con.id;
}

Let me know if this makes sense. Thanks

All Answers

tonante27tonante27
HI,
 
If I understood your question correctly you can pass the contact look up ID field value to the webservice as:
IVR_Journey__c con = new IVR_Journey__c();
/* Add other Assignment statements for  the IVR_Journey__c custom object fields here */
/*Add a new contact and assign it to the IVR_JOurney__r.Contact__c object */
con.Contact =  insert (new Contact(FirstName,LastName,Email)); 



You need to point that Contact ID  field of IVR_Journey__c to an existing Contact Id.  So now you have:
 
IVR_Journey__c con = new IVR_Journey__c();
con.Caller_ID__c = Integer.valueOf(CallerID);         
con.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);  
con.DNIS__c = Integer.valueOf(DNIS);
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate); 
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
Contact someContact = new Contact(FirstName="Some",LastName="Person",Email="someperson@mailinator.com"));
insert someContact;
con.Contact = someContact;

insert con;
return con.id;

Is this what you meant to do?
 
VRKVRK
Hi tonante27
Thanks for your response...
i will explain my question clearly .............
in contact object , i have contacts like  'test1','test2','test3, test4'.........................
i created custom object 'IVR-Jorney_c' and cretae lookup relationship between contact and IVR_Journey_c object.
Now,, third party sending custom object details along with test1 contact .... i can able to save custom object details but not contact 'Test1'.

i hope you can clear now ....pls check the code and let me know how can pass Test1 contact ?  Thanks



 
tonante27tonante27
Sekar:  First you need to pass into the webservce an ID Parameter type for the contact Id (test1---.. etc).. I call it ContactId.
Test1 contact only neds to send its Id as parameter list not the full contact.
Then you need to assign that ID to the Contact Id parameter  to  con.Ivr_Journey__c.  Here is what I mean:
 
global class IVRObjWebservice
{
    webservice static Id createIVRRecord(String CallerID, String ContactChannel,String ContactIntent,String AuthenticationResult,Id ContactId <------ Id of Contact
                                         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.Seq_Member_ID__c = Integer.valueOf(SeqMemberID);  
con.DNIS__c = Integer.valueOf(DNIS);
con.Start_Date_Time__c = Datetime.valueOf(startdate);        
con.End_Date_Time__c = Datetime.valueOf(enddate); 
con.Contact_Channel__c = ContactChannel;
con.Contact_Channel_Duration__c = ccChannelDuration;
con.Ivr_Journey__c = ContactId;
insert con;
return con.id;
}

Let me know if this makes sense. Thanks
This was selected as the best answer