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
msc7808msc7808 

Need Help

Hey Guys,

 

I have defined two custom objects as follows:

 

(1) Hotel                        Record Name:    HotelName

(2) CustomContact        Record Name:    Full Name           Sec Field   Hotel: Lookup(Hotel)

 

I have Apex Code

 

 CustomContact__c[] contacts = new CustomContact__c[0];
contacts.add(new CustomContact__c(Business_Title__c='test',TypeofContact__c='Hotel',Hotel__c=HotelName,Name='John Doe'));

 

I am getting an error: 

 

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:'System.StringException: Invalid id: Dummy Hotel Class.WSUpdates.InsertHotelContacts: line 39, column 115', }

 

Please advise what could be wrong.

 

THanks

 

Manny

EtienneCoutantEtienneCoutant

It looks like your variable HotelName is the String 'Dummy Hotel', instead of the Salesforce ID associated with Dummy Hotel.

 

Something like that should work:

 

Hotel__c hotel = new Hotel__c(Name='Dummy Hotel');

 

CustomContact__c[] contacts = new CustomContact__c[0];

 

contacts.add(new CustomContact__c(Business_Title__c='test',TypeofContact__c='Hotel',Hotel__c=hotel.Id,Name='John Doe'));

 

 

 

Message Edited by EtienneCoutant on 07-06-2009 08:28 AM
msc7808msc7808

Thanks. I will try this.

 

I did try an alternative by passing the ID of the Hotel Record from the Custom Button as a parameter which executed the APEX. It worked fine. :)