I am having a requirement to create contacts using Salesforce-Bulk-API in salesforce account. My question is can we also create custom fields for Contact object in salesforce using bulk API?
salesforce = SalesforceBulkApi::Api.new(#client)
records_to_insert = Array.new
socialcrm_list.socialcrm_list_records.each do |record|
new_record = {"FirstName" => record.first_name, "LastName" => record.last_name, "Email" => record.email1, "Phone" => record.phone1, "HomePhone" => record.phone3, "MobilePhone" => record.phone2, "MailingStreet" => record.address1, "MailingCity" => record.city,"MailingState" => record.state, "MailingCountry" => record.country, "MailingPostalCode" => record.zip, "CustomField" => record.job}
records_to_insert.push(new_record)
I have tried passing CustomField as an attribute in the hash, but it is not working. Is there any way we can pass extra attributes in Hash without adding them exclusively from Salesforce developer Account
Attached a reference image of sales-force custom attribute form over here
Related
I am using Ruby on Rails framework. I want to add tag along with contact but its giving me error of "[NoFieldFound]No field found: Contact.Tags2". I am using following code:
Infusionsoft.contact_add({:FirstName => 'Amy', :LastName => 'Smith', :Email => 'amysmith#gmail.com', :Tags2 => 244})
Can anyone please help me? How can we add tags along with contacts?
Preet, to add tags to a contact in Infusionsoft, you first need to add the contact, and then add the contact to a group (i.e. apply a tag)
In Ruby, you'd run:
Infusionsoft.contact_add_to_group(contact_id, group_id)
contact_id is the ID of the contact you created.
group_id is the ID of the tag you want to apply, 244 in your example.
So to add a contact and then apply a tag, you'd run something like this:
contact_id = Infusionsoft.contact_add({:FirstName => 'Amy', :LastName => 'Smith', :Email => 'amysmith#gmail.com'})
Infusionsoft.contact_add_to_group(contact_id, 244)
I'm working with the Amazon Product Advertising API and I'm trimming its responses within my controller to render customized JSON, but its responses change a lot depending on the product category, so I need to write code that can catch all of the ways it changes. I only need a few pieces of data, so how can I simply check to see if those pieces exist within Amazon's API response before including them in my own custom JSON?
Note: I'm using this gem to integrate with Amazon's API. It returns the API responses in its own objects.
#results = (Amazon's API response)
#custom_response = []
#results.items.each do |product|
#new_response = OpenStruct.new(
:id => product.asin,
:source => "amazon",
:title => product.title,
:price => #product_price,
:img_small => #images[0],
:img_big => #images[1],
:category => product.product_group,
:link => "http://amazon.com/" )
#custom_response << #new_response
end
You can try something like this:-
#new_response = OpenStruct.new(:source => "amazon", :link => ".....")
#new_response.id = product.asin if product.asin.present?
#new_response.title = product.title if product.title.present?
other attributes....
I'm trying to figure out how I can use the Gibbon gem in Rails to automatically add subscribers to specific interest groups in MailChimp?
I've found this article which details a non-Rails method for doing so: http://roman.tao.at/uncategorized/mailchimp-api-listsubscribe-listbatchsubscribe-and-groups/
I'd like to figure out how to implement that functionality using the Gibbon gem: https://github.com/amro/gibbon
FYI, I'm also a novice with both MailChimp and Rails.
Finally, after hours of perusing through code. I've found the example I'm looking for!
Thanks to TJ Moretto for providing this on a Google Groups thread:
I'm using the gibbon gem, but ran into the same types of issues.
Here's how I had to format the parameters to finally get this to work:
gb.list_subscribe({:id => "#{list.id}",
:email_address => user.email,
:update_existing => true,
:double_optin => false,
:send_welcome => false,
:merge_vars => {'FNAME' => "#{user.first_name}",
'LNAME' => "#{user.last_name}",
'GROUPINGS' => {0 => {'id' => grouping.id, 'groups' => "#{challenge.name}"}}}
})
Hope that helps.
Mailchimp Team - based on the number of issues that everyone runs into
when trying to do this (across all programming languages), I suggest
you update the API documentation to be more clear.
Update for version 2.0 of the MailChimp API and version 1.0 of Gibbon (For #Calin and posterity). Here are the necessary changes from the previous version. The API object is accessed like this now:
gb = Gibbon::API.new
And list methods like so:
gb.lists.subscribe(params)
Finally the :email_address parameter has been replaced by the :email parameter, which should be given a value of the following form: The value should itself be a hash with one key, either 'email' or 'leid', and the value should be either the email address of the subscriber or MC's unique identifier (LEID) for the subscriber.
So a full subscription call might look something like this:
gb = Gibbon::API.new
gb.lists.subscribe(:id => "ed6d1dfef4",
:email =>
{ "email" => "example#domain.com" },
:merge_vars =>
{:groupings =>
{
0 => { :id => "95", :groups => ["Some Group", "Another Group"]},
1 => { :id => "34", :groups => ["A Third Group"]}
}
},
:update_existing => "true",
:double_optin => "false",
:replace_interests => "false")
I have a group#view page, that is accessed by a Person. In this page, the Person can see the members of the group via methods I developed. The problem is that I need to create the model Honors using the Id from the group, the id from the person accessing the page, and the id from a member of this group.
In my Honors controller I have:
def create
#person = Person.find(current_person)
#honor = Honor.create(:group => Group.find(params[:group_id]),
:person => Person.find(current_person), :honored => Person.find(current_person))
if #honor.save
...
end
The problem is in this :honored => Person.find(current_person), that is not getting the right ID and I don`t know how to get it.
In my view:
<% #asked_groupmembership.each do |agm| %>
<% form_for(:honor, :url => honors_path(:group_id => #group.id, :person => current_person.id,:honor => agm.member.id)) do |f| %>
Any help?
Thanks.
If you need 3 components to properly create an honor record, you need to pass them from the form. You seem to be doing that part correctly.
:group_id => #group.id
:person => current_person.id
:honor => agm.member.id
To create the record, access the passed variables.
Honor.create(:group => Group.find(params[:group_id]),
:person => Person.find(params[:person]),
:honored => Person.find(params[:honor]))
Understanding the above isn't the most efficient, but used for demonstrative purposes. You'd likely want to avoid redundant database hits, e.g. :person => current_person rather than another query
I am using RiCal gem to create calendar event in my ROR project. The issue i have is when i add attendee it adds the attendee as .
ATTENDEE:mailto:sanjay.swain#in.ibm.com
ATTENDEE:mailto:sanjayswa#gmail.com
But I want ATTENDEE as
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=sanjay.swain#in.ibm.com;X-NUM-GUESTS=0:mailto:sanjay.swain#in.ibm.c
om
with ROLE, PARTSTAT etc.. Is there a way to get this result using RiCal gem..
I found the solution. Here is what I have done:
options = {'CUTYPE' => 'INDIVIDUAL','RSVP' => 'TRUE','ROLE' => 'REQ-PARTICIPANT','PARTSTAT' => 'NEEDS-ACTION','X-NUM-GUESTS' => '0'}
attendee_property = RiCal::PropertyValue::CalAddress.new(nil, :value => "mailto:"+attend, :params => options)
event.attendee_property = attendee_property