sugarcrm icon indicating copy to clipboard operation
sugarcrm copied to clipboard

Documents and Workflows

Open pjsim opened this issue 12 years ago • 10 comments

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?

pjsim avatar Feb 13 '14 22:02 pjsim

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

chicks avatar Feb 13 '14 23:02 chicks

PS, Congrats on being the 100th issue submitter!

chicks avatar Feb 13 '14 23:02 chicks

Ah thank you! and thanks for the prompt response :)

pjsim avatar Feb 13 '14 23:02 pjsim

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.

pjsim avatar Feb 14 '14 00:02 pjsim

Also for the logic hooks, these would need to be done in PHP?

pjsim avatar Feb 14 '14 00:02 pjsim

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.

pjsim avatar Feb 14 '14 06:02 pjsim

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.

chicks avatar Feb 15 '14 19:02 chicks

I suppose I would be using the newest version but I really don't know PHP at all.

pjsim avatar Feb 16 '14 10:02 pjsim

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!

andrew2005 avatar Mar 01 '14 09:03 andrew2005

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.

chicks avatar Mar 24 '14 17:03 chicks