Drop me a line and we can discuss!
> --
> You received this message because you are subscribed to the Google Groups
> "ActiveSalesforce" group.
> To post to this group, send email to activesa...@googlegroups.com.
> To unsubscribe from this group, send email to
> activesalesfor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/activesalesforce?hl=en.
>
Cannot deserialize instance of date from VALUE_STRING value at [line:1, column:77]
Rails.root: /Users/raygao2000/Desktop/12_recipes_book/recipe2/MyFitness
app/controllers/participants_controller.rb:64:in `block in create'
app/controllers/participants_controller.rb:63:in `create'
Parameters:
{"utf8"=>"✓", "authenticity_token"=>"E98bukMKc/K1mMTLbyBkzRjdWNIkPtsuuJWwujycfeI=", "participant__c"=>{"OwnerId"=>"005U0000000ZZGoIAO", "Owner"=>"005U0000000ZZGoIAO", "Email__c"=>"r...@jj.com", "Date_of_Birth__c"=>Thu, 01 Dec 2011, "Gender__c"=>"male", "ProgramStartDate__c"=>Thu, 01 Dec 2011, "ExpectedEndDate__c"=>Thu, 01 Dec 2011, "Last_Name__c"=>"james", "First_Name__c"=>"pit"}, "commit"=>"Create Participant c"}
Headers:
Hi,I am trying to create a new record in the Database.Com with this GEM. I could not get it to work.The schema is as follows.
The form creating the record is:
<%= form_for @participant, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |form| %><% Participant__c.attributes.select {|a| Participant__c.updateable?(a)}.each do |attr| %><field><%= form.label attr, Participant__c.label_for(attr) %><% case Participant__c.field_type(attr) %><% when "boolean" %><%= form.check_box attr %><% when "multipicklist" %><% when "picklist" %><% puts "Rendering picklist for #{attr}, value is #{@participant[attr]}, type is #{Participant__c.field_type(attr)}"%><%= form.select attr, Participant__c.picklist_values(attr).collect {|p| [p["label"], p["value"]]}, :multiple => (Participant__c.field_type(attr) == "multipicklist") %><% else %><%= form.text_field attr%><% end %></field><br><% end %><%= form.submit %><% end %>This creates a page:
<field> <label for="participant__c_OwnerId">Owner ID</label> <input id="participant__c_OwnerId" name="participant__c[OwnerId]" size="30" type="text" /> </field> <br> <field> <label for="participant__c_Owner">Owner ID</label>
<input id="participant__c_Owner" name="participant__c[Owner]" size="30" type="text" /> </field>
I have records saving with various field types, including dates. If
the error is coming back from Salesforce, then I believe the issue is
that you are setting the property to a String, when it should be a
Date. Try converting the value in your Ruby code to Date and then
setting Participant__c.Date_of_Birth and I think you should be okay.
You can always try testing it with Time.now.to_date to verify that it
will accept a known-good date.
result = @participant.update_attributes(params[:participant__c])
results in errors. Net::HTTPBadRequest exception.
- even though, the JSON from debugger is:
{"Email__c":"la...@are4.us","Date_of_Birth__c":"1972-10-10","Gender__c":"male","ProgramStartDate__c":"1900-10-10","ExpectedEndDate__c":"1992-10-10","Last_Name__c":"james","First_Name__c":"lady"}
- path is:
http://xxxxxxxxxx -> /services/data/v23.0/sobjects/Participant__c/a05U0000000XGdvIAG
That looks perfectly correct to me.
What could be problem here? What is the correct way for updating a record from a web form?
best
-R
@participant = Participant__c.find(params[:id])
puts '--------started saving----------'
result = @participant.save
At this time, I have no clue how to fix this issue - updating an existing record.
-Ray
***** RESPONSE: Net::HTTPCreated ->
{"id":"a06K00000011SztIYW","errors":[],"success":true}
Or from a query (that didn't find anything):
***** RESPONSE: Net::HTTPOK -> {"totalSize":0,"done":true,"records":[]}
Try that and feel free to send over the output from the log. I'm not
sure I'll be able to help a lot but maybe one of the guys from
Salesforce may have some ideas.
OK, the update() method definitely has a bug. According to the debugger, the @Request_has_body is true. But, @Body is in fact nil.This is a really serious problem. Basically, you can't update any records with the DatabaseDotCom Gem unless this bug is fixed.It took me a while to step into all the code. But, this really needs to be fixed right way.
-R<PastedGraphic-1.tiff>
> client.materialize("User")
> u = SFDC_Models::User.query("FirstName='Mason'")
> u[0].CompanyName = 'Test'
> u[0].save
It worked just fine, and I logged into SFDC and viewed the user to
verify that the update went through and the new CompanyName value was
there.
I'm using databasedotcom 1.2.5, if you want to double-check.
Really hated to dwell on this issue.
Anytimes, you have a field that is unique for a record, you cannot update it with the gem. Since, the GEM passes back the entire record (including the unique field), the system will block it.
Something really needs to be fixed. Otherwise, this is a pretty serious problems. A lot of apps will have unique field (secondary keys). And, you cannot update those field.
-R
I have certainly done updates to objects that have unique fields and
it has worked fine, so I just want to make sure I understand the
issue.
Thanks.
-R
When I tried to update the record, Email__c field is send back as well. As Email__c is unique, a previous record already existed in the system. Thus, it won't let me create another one.
There is a slight issue with the exception handling logic of the gem. It is eating up Message Body from database.com response. It displays only "Net::HTTPBadRequest". The real message "HTTP code 400: duplicate value found: Email__c duplicates value on record with id: a05U0000000XKb8" got eaten up by the GEM.That's why it is so confusing.I had to go back to my old gem to figure this out. In my old GEM, I hadraise Salesforce::Rest::AsfRequestError.new(message, http_code)This shows the message body.But, in the new gem, there is only:raise SalesForceError.new(response) unless response.is_a?(expected_result_class || Net::HTTPSuccess)
I hope the Exception handling logic can be enhanced.
--
You received this message because you are subscribed to the Google Groups "ActiveSalesforce" group.
To post to this group, send email to activesa...@googlegroups.com.
To unsubscribe from this group, send email to activesalesfor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activesalesforce?hl=en.
Thanks, -R