ionia-corporation / active_force Goto Github PK
View Code? Open in Web Editor NEWUse Sales Force as an Active Model
License: MIT License
Use Sales Force as an Active Model
License: MIT License
Hello !
Do you know if there is a way to use your gem with the geocoder
or searchkick
gem ?
I'm trying to find Account
records near to a latitude/longitude.
Do you have any idea to help me ?
Thanks !
Adding support for upsert
would save an API call in some use cases. It should maybe be called find_or_create
and follow ActiveRecord semantics. Restforce supports upsert
.
Is anyone else interested? Was this already discussed?
I have an application where each user authenticates using omniauth to Salesforce to get their own Restforce client for requests to Salesforce.
What's the best way to override the active_force.SObject.client to allow for this to be used, rather than setting up a new Restforce connection that uses application wide environment variables?
To prevent stuff like below from happening:
https://www.dropbox.com/s/32yu3nnrd8pooqa/Screenshot%202015-11-12%2010.04.52.png?dl=0
Which prevents save/create of models if the user makes mistake of specifying field names as strings instead of symbols.
It will require activesupport as a dependency, however since most people using this gem will already be using rails, I don't see any reason not to add that dependency. Also if you add active model as a dependency as per #95 , dependency will be met anyways. Im happy to PR if you will accept.
module Salesforce
class BusinessyThing < ActiveForce::SObject
end
end
pry(main)> Salesforce::BusinessyThing.table_name
=> "Salesforce::BusinessyThing__c"
In the case of the following class:
class Account < ActiveForce::SObject
field :id, from: 'Id'
field :thing_id, from: 'Thing__c'
belongs_to :thing
end
it would be nice to be able to send a single API request which also build the object in memory to include the relations, similarly to ActiveRecord, like so:
pry(main)> Account.includes(:thing).where(' Id != NULL').to_s
=> "SELECT Id, Thing__c, Thing__r.Id, Thing__r.OtherThingFields FROM Account WHERE Id != NULL"
pry(main)> account = Account.includes(:thing).first
=> #<Account id: "001V000000EwBR0IAN", thing_id: "00580000005sD0hAAE">
pry(main)> a.thing
=> #<Thing id: "00580000005sD0hAAE"> # loaded without separate API request.
Generating a model from a camel case standard type generates incorrect filenames and class names.
i.e
SiteHistory creates the following
sitehistory.rb
class Sitehistory < ActiveForce::SObject
end
Should instead be the following
site_history.rb
class SiteHistory < ActiveForce::SObject
end
Given:
class Case < ActiveForce::SObject
field :id, from: 'Id'
end
kase = Case.find 123
kase.update_attributes! foo: 'bar' # This should fail loudly.
When trying to update an attribute not declared, ActiveForce should fail loudly. Instead it just ignores the parameter, without even sending it to Salesforce API (which would at least complain).
It would be very useful to be able to do Account.select(:id, 'Name').all
and have it only return the Id and Name columns.
It would seem that the list is a bit sparse, and it should include all of the objects listed here:
https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
Hello all !
I don't know why but i'm not able to access to latitude and longitude include in location field :
undefined method `latitude' for "#<Restforce::Mash latitude=43.0082399 longitude=-88.0568406>":String
Extracted source (around line #13):
if @accounts
@hash = Gmaps4rails.build_markers(@accounts) do |account, marker|
raise account.location.latitude.inspect
# marker.lat account.location.latitude
# marker.lng account.location.longitude
marker.infowindow account.name
Could you help me to understand why ?
Example:
field :some_attribute
should eq
field :some_attribute, from: "Some_Attribute__c"
If I have a relationship defined like so:
class Lead < ActiveForce::SObject
field :business_partner_id, from: 'Business_Partner_Id__c'
belongs_to :business_partner, model: Account, foreign_key: :business_partner_id
end
It would be nice if there wasn't an API call for every @lead.business_partner
call, and instead it only needed to be loaded once.
Not sure what the solution is, but it would be cool if this worked.
Currently, this happens.
[1] pry(main)> Opportunity.where(id: 1..3).to_s
=> "SELECT Id FROM Opportunity WHERE Id = 1..3"
Remove field :id generation
Remove requiring sobject at top of the file
Should test the value transformation when saving to SFDC. Example:
class Led < SObject
field :colors, as: :multi_picklist
end
some_led.colors = ['Red', 'Blue']
Client should receive query with "Colors__c = 'Red;Blue'"
currently it's not working because read_value isn't being called when creating/updating
It seems that this method is the only reason for having to declare Client
during initialization. Could this just specify Restforce.new
like this method and do away with that?
Set the default client as Restforce.new in SObject.
It would be useful to be able to reference a table's primary key with a class method. Although this is usually just 'Id', in rare cases it may be different, so it would also be nice to have a setter for this on the class level.
Could someone bump the version? I have a gem that integrates this with CanCan, but it relies on commit 1d5948cd08230349b1fa7d382fbf2787ebc20a1f.
Delegate to to_a.
From the README:
class Account < ActiveForce::SObject
has_many :medications,
where: "Discontinued__c > #{ Date.today.strftime("%Y-%m-%d") }" \
"OR Discontinued__c = NULL"
end
This Date.today
will only be evaluated when the account class is loaded, and it will not be reevaluated when called: (account.medications
). If I boot a Rails app with this code on a Monday, and then on Wednesday I call Account.find('someid').medications
, the query will use Monday's date in the where clause.
I would like to have a class method to define some other methods to be called after or before the update, create or save actions.
class Account < ActiveForce::SObject
before_save :set_default_values
private
def set_default_values
self.some_field = 0
end
end
We are currently using a patched version of ActiveAttr, but I think that it was a bad design decision, I'm almost sure that we should remove this dependency and use ActiveModel using these instructions instead.
I think that this is important as it will simplify the gem and will make it easier to maintain and understand.
Missing Google Docs from default types that don't have the __c appended to them while querying
The 'Id' field is a standard field on all Salesforce Objects, so it seems redundant to specify it in each class declaration with:
class Lead < ActiveForce::SObject
field :id, from: 'Id'
end
It would be nice to be able to just supply a Hash or array of arguments to be 'and'-ed, similar to ActiveRecord.
For example:
class Lead < ActiveForce::SObject
field :id, from: 'Id'
field :name, from: 'Name'
field :title, from: 'Title'
end
allows
pry(main)> Lead.where("Name = ? AND Title = ?", 'Jim Jones', 'Mr.').to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Name ='Jim Jones' AND Title ='Mr.'"
or
pry(main)> Lead.where(name: 'Jim Jones', title:'Mr.').to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Name ='Jim Jones' AND Title ='Mr.'"
An added bonus would be if this would also guard against any potential SOQL Injection issues, such as:
pry(main)> params = {id: "'' OR Id != null"}
pry(main)> Lead.where("Id = ?", params[:id]).to_s
=> "SELECT Id, Name, Title FROM Lead WHERE Id = ''''' OR Id != null'"
I would like to know it this gem can be used on Rails 5 projects. Someone have experience working with this gem on Rails 5 projects?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.