Closed wizardone closed 12 years ago
Hrm... Can you share the code you are using to load the data from the CSV? I do this pretty regularly and I haven't run into this (yet).
Sure, but first i have to clarify that the problem does not occur during the initial insert of data. The data has already been inserted, but when i try to create the corresponding Security Groups(to group the various entries, which i`ve inserted) it happens.
if @isos
@logger.info("Puting ISOs into ISO groups")
role = @sugarcrm_namespace::ACLRole.find_by_name("isos")
@isos.each do |iso|
unless find_sugarcrm_object('security_group','name', iso.name)
sg = @sugarcrm_namespace::SecurityGroup.new(:name => iso.name)
@logger.info("Security group for iso #{iso.name} not found, created one called #{sg.name}")
user = @sugarcrm_namespace::User.find_by_last_name(iso.name)
@logger.info("Puting Iso #{iso.name} and User #{user.last_name} in Security Group #{sg.name}")
sg.save!
iso.associate! sg
user.associate! sg
role.associate! sg
end
end
end
- @isos - the custom object in SugarCRM
Now this method works completely fine for the first several records, than at some point i receive the "name"=>"Invalid Session ID" response in my session. I just don`t know what to do anymore. Also tried to to set the max_retriesto a bigger number in case there was some connection problem, but it was no good. :( Thanks for the feedback, i hope we can fix this somehow.
Can you expand on your usage of @sugarcrm_namespace? Why aren't you just using SugarCRM::ACLRole.find_by_name("isos")? Are you connecting to multiple SugarCRM instances?
@sugarcrm_namespace holds the connection to my instance of SugarCRM. And no, i`m using a single connection.
The connection is a singleton in the SugarCRM namespace, so you don't need to assign the result of SugarCRM.connect to a variable. Can you try replacing @sugarcrm_namespace with SugarCRM in your code?
Hi, i've been able to fix this bug. As it seems the problem were the quotes. As i told you i was importing data from csv files and i saw that Invalid Session was returned when i was inserting a particular record. It had double quotes in it's name, so after removing them everything ran smoothly(this also happend to another record so i can absolutely verify that this was the issue). How this could corrupt the whole session - i don't know, but thanks for the assistance. P.S. I didn`t replace the @sugarcrm_namespace prior to fixing this, but i will now, thanks.
Ahhhhh! I've seen that before - sorry I didn't suggest it earlier. We try to escape characters before we send them over, but there's a bug in SugarCRM which prevents us from handling all cases properly.
Sorry to bother with this problem again, but i'm receiving this error again in a completely different case and i just don`t know how to debug anymore, since it is as generic error as it gets. No quotes this time. Script working fine on my local MacOS, but when deployed on Ubuntu 12.04 everything fails. I am again importing information from csv files, but no matter what i import i will always get this error. Tried to set the encoding of the csv files to utf-8, but nothing.
I got the same error, but found when it has been appear. When in string for save/update object exist this one <
and &rt;
. So my hot fix is string.gsub!(/\</, '')
and string.gsub!(/\&rt;/, '')
I've been brainstorming this for quite a while now. I`m importing information from csv files into SugarCrm and at some point i get an "invalid session" thrown. I checked the the following code: rescue SugarCRM::InvalidSession => error @errors << error old_session = @sugar_session_id.dup login!
Update the session id in the request that we want to retry.
and after some debugging i found out that the session was not updated( old_session == @sugar_session_id after the login! method which should update the session_id). I tried to mess with the code a little bit, tried to logout, then login again but nothing seems to help. Any ideas?