You need to sign in to do that
Don't have an account?
msc7808
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
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'));
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. :)