CFD c# phonebook lookup

Status
Not open for further replies.

Aljosa Pregun

Customer
Advanced Certified
Joined
Jan 28, 2017
Messages
8
Reaction score
2
Hi,
i still have some issues with getting the called name from 3cx phonebook using the c# code and execute c# code cfd component.

I'm using the following code:
C#:
PhonebookEntry Contact = PhoneSystem.Root.GetTenant().FindContacts(strANI,6) as PhonebookEntry;
return Contact.Firstname + " " + Contact.Lastname;

Capture.PNG


I get the following error when i upload the cfd zip file to 3cx:

Code:
:[37573..37587)E: (813,12)-(813,26): Error CS0246: The type or namespace name 'PhonebookEntry' could not be found (are you missing a using directive or an assembly reference?)
            PhonebookEntry Contact = PhoneSystem.Root.GetTenant().FindContacts(strANI,6) as PhonebookEntry;
            ^^^^^^^^^^^^^^
:[37653..37667)E: (813,92)-(813,106): Error CS0246: The type or namespace name 'PhonebookEntry' could not be found (are you missing a using directive or an assembly reference?)
            PhonebookEntry Contact = PhoneSystem.Root.GetTenant().FindContacts(strANI,6) as PhonebookEntry;

I would like to get the caller first and last name to use it in email notifications, voicemail email notifications and database insert that is configured in the rest of cfd process.

Please provide some help.

thank you.
 
The FindContacts method returns an array of PhoneBookEntry. Also, the case you're using is not correct, it's PhoneBookEntry and not PhonebookEntry.

Your code should be:
C#:
PhoneBookEntry[] contacts = PhoneSystem.Root.GetTenant().FindContacts(strANI,6);
return contacts.Length > 0 ? contacts[0].Firstname + " " + contacts[0].Lastname : "";
 
  • Like
Reactions: Evolute IT
Hi,
thank you for your reply but i get the following error when importing the cfd file using the code you provided:

Code:
:[39960..39969)E: (832,41)-(832,50): Error CS1061: 'PhoneBookEntry' does not contain a definition for 'Firstname' and no accessible extension method 'Firstname' accepting a first argument of type 'PhoneBookEntry' could be found (are you missing a using directive or an assembly reference?)
return contacts.Length > 0 ? contacts[0].Firstname + " " + contacts[0].Lastname : "";    }
                                         ^^^^^^^^^
:[39990..39998)E: (832,71)-(832,79): Error CS1061: 'PhoneBookEntry' does not contain a definition for 'Lastname' and no accessible extension method 'Lastname' accepting a first argument of type 'PhoneBookEntry' could be found (are you missing a using directive or an assembly reference?)
return contacts.Length > 0 ? contacts[0].Firstname + " " + contacts[0].Lastname : "";    }
                                                                       ^^^^^^^

Thank you.
regards,
 
The problem is the case again, I copied your code without noting it. The properties are FirstName and LastName, the case is important.
 
  • Like
Reactions: Evolute IT
The problem is the case again, I copied your code without noting it. The properties are FirstName and LastName, the case is important.

Thanks a lot. You are a lifesaver. This works.
Regards
 
  • Like
Reactions: edossantos
Status
Not open for further replies.

Forum statistics

Threads
111,854
Messages
589,400
Members
164,693
Latest member
FLCC