You need to sign in to do that
Don't have an account?
Pranav Nair
Adding invitees to Salesforce Event
Hi, I'm new to this area and need some help. I have a Google Event with a list of invitees. I have a python code which syncs this event with Salesforce by creating a Event sObject. I queried for the emails in the invitees list of my Google event to check whether such a contact exists.
Now I want to add Invitees through my python code to the Event sObject created in sync with Google Event. I am using salesforce-python-toolkit for the same.(https://github.com/BayCitizen/salesforce-python-toolkit). This is a snippet of the code i have implemented so far. (here eventData is a dictionary containing the information about the event)
But this is not updating the event on my salesforce developer account online, and I cant seem to find the problem. Please suggest changes to this code.
Thanks!!
Now I want to add Invitees through my python code to the Event sObject created in sync with Google Event. I am using salesforce-python-toolkit for the same.(https://github.com/BayCitizen/salesforce-python-toolkit). This is a snippet of the code i have implemented so far. (here eventData is a dictionary containing the information about the event)
h=SforceEnterpriseClient('file://localhost/path-to/wsdl.jsp.xml') h.login('username','pass','token') event = h.generateObject('Event') event.Subject = eventData['title'] event.Location = eventData['location'] event.Description = eventData['description'] acceptedIds = [] for email in eventData['invitees']: #query their contacts database using suitable query to check whether a contact who is invitee is available query_contact = h.query("SELECT Id,Name FROM Contact WHERE Email=" + "'" + email + "'") if query_contact.size != 0 : for record in query_contact.records: acceptedIds.append(record.Id) event.AcceptedEventInviteeIds = acceptedIds result = h.create(event) h.logout()
But this is not updating the event on my salesforce developer account online, and I cant seem to find the problem. Please suggest changes to this code.
Thanks!!
I would try making two changes to your code above. First, I'd change the query in line 11 to look like the following:
Second, I think you are missing some required fields for the event object and that is why line 16 fails to create a new event record in Salesforce. After line 6 try setting the ActivityDate field and the IsAllDayEvent field (with something similar to below) to see if that solves the problem:
For more information on the event object in Salesforce I'd recommend checking out this page: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_event.htm
All Answers
I would try making two changes to your code above. First, I'd change the query in line 11 to look like the following:
Second, I think you are missing some required fields for the event object and that is why line 16 fails to create a new event record in Salesforce. After line 6 try setting the ActivityDate field and the IsAllDayEvent field (with something similar to below) to see if that solves the problem:
For more information on the event object in Salesforce I'd recommend checking out this page: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_event.htm
I implemented the changes you suggested, and the event now shows up in the calendar,but when i click on the contacts who have accepted the event, it does not show up in their open activities section. pls suggest.
My guess is that your SOQL query is not returning any contact records then; I'd try to do some debugging to be sure you are getting results.
Upon looking closer at your code it also looks like you query the database inside a for loop that iterates over a list of email addresses. I'd suggest removing this by changing your query to find all contacts with an email equal to any one of the values in eventData['invitees'].
Hope that helps,
Scott