Documents and Workflows
Hi, I've been trying out this gem today and I need to use the API with documents (uploading,downloading,sorting) and possibly with workflows as well. I can't find much information and how to do these though. The one upload example in the README I can't get to work (seems there is no uploadfile method). Is there any more information on how to use these somewhere?
Yeah, I think I updated the README before ever finishing that code :(
So, to upload files use set_note_attachment... something like this:
https://github.com/chicks/sugarcrm/blob/master/lib/sugarcrm/connection/api/set_note_attachment.rb
You can access this method like:
SugarCRM.connection.set_note_attachment(note_id, filename, file_object)
set_note_attachment: Request:
{
"session": "eubisbbcntp13gcvmq9nlcess1",
"note": {
"id": "62891ccc-07ef-154d-2870-52716ea9e586",
"filename": "GartnerAnalytics.pdf",
"file": "JVBERi0xLjQKJeHp69MKNiAwIG9iag…",
"related_module_id": "",
"related_module_name": "",
}
}
You'll need to create a note, and attach the document to that note, then create a relationship between the note and the record that you want it to show up on... not the best approach, but start there.
As far as workflows, the best option is to trigger workflow actions via logic_hooks (similar to ActiveRecord callbacks).
http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.7/03_Module_Framework/Logic_Hooks
PS, Congrats on being the 100th issue submitter!
Ah thank you! and thanks for the prompt response :)
Hi some more questions sorry.
How do I get a valid file object variable from something like a file in the params variables? (like I have a params[:document] from an upload form)? Everything I have tried sayts it is either an empty file or is invalid for sugar.
Is this method only for attachments on notes? I was hoping be able to have a document with revisions that I could then attach to a note or a contact/lead.
Also for the logic hooks, these would need to be done in PHP?
and other one.
if I use the get_note_attachment method am I doing this right?
n = SugarCRM::Note.all.first
SugarCRM.connection.get_note_attachment(n.id)
The code above says invalid data.
Sorry about all the questions. We are trying to asses which CRM is best for our rails site and time is running short.
Logic hooks are done in php, yes. If your instance is On-Demand, you can build a module loadable package for them... Something like this: http://support.sugarcrm.com/04_Find_Answers/03_Developers/Module_Loader/Examples/Creating_an_Installable_Package_for_a_Logic_Hook
Which version of Sugar are you using? The API I built this for is pretty old and in version 7 there's a much better REST API.
I suppose I would be using the newest version but I really don't know PHP at all.
chicks, I'm just starting my project now, if I just need the ability to query objects, what would be your suggestion? Would your gem still be the way to go or is the API too old?
Your work looks great and would love to use it, was just a bit concerned by what you said. :)
Thanks and keep up the great work!
Gem works fine for query and updates! It's really just a wrapper around the v2 web services library, which is still quite functional and supported.