Open rwold77 opened 11 years ago
@chicks - Any updates on this issue?
We try to make things more active_record centric by adjusting the names, but sometimes this backfires and creates more confusion. :)
Be conscious of where you are using the Sugar Module name, vs. where you are using the SugarCRM gem Model name. When you use a native REST method, like get_fields, the first argument needs to be the Sugar Module name. Specifically, in this case it would be "Goal_Goal".
So, just keep track of which layer you are working at. If you want to get a list of fields at the Model layer, try this:
SugarCRM::GoalGoal._module.fields
If you want to get a list of relationship fields, try this:
SugarCRM::GoalGoal._module.link_fields
And to get the list of modules:
SugarCRM.modules
I'm trying to pull records from a custom module using the .all function. I found the issues that mention that the underscore is removed from custom modules, and updated my code based on that, but there don't seem to be any fields associated with that name. I am very new to ruby, so please tell me if I'm doing something stupid.
mySession = SugarCRM.connect(......)
puts "#{mySession.modules}"
The output from this command says the module name I need is GoalGoal.
puts "GoalGoal: #{mySession.connection.get_fields("GoalGoal")}" : GoalGoal: {"name"=>"Module Does Not Exist", "number"=>20, "description"=>"This module is not available on this server"}
mySession::GoalGoal.all(:conditions => {:assigned_user_id => seller.id, :target_type => 'dollars'}) : : Database failure. Please refer to sugarcrm.log for details.
puts "Goal_Goal: #{mySession.connection.get_fields("Goal_Goal")}" : Goal_Goal: {"module_name"=>"Goal_Goal", "module_fields"=>{"id"=>{"name"=>"id", "type"=>"id", "label"=>"ID", "required"=>1, "options"=>[]}, ....."}}}
mySession::Goal_Goal.all(:conditions => {:assigned_user_id => seller.id, :target_type => 'dollars'}) : uninitialized constant SugarCRM::Namespace1::Goal_Goal
So, to summarize, the .modules function says the name is GoalGoal, but there are no fields associated with that, and if I try to pull records, I get a database error.
The real name is Goal_Goal, and there are fields found for that name, but when I try to pull records, I get a namespace error.
Please help.