Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documents and Workflows #100

Open
pjsim opened this issue Feb 13, 2014 · 10 comments
Open

Documents and Workflows #100

pjsim opened this issue Feb 13, 2014 · 10 comments

Comments

@pjsim
Copy link

pjsim commented Feb 13, 2014

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?

@chicks
Copy link
Owner

chicks commented Feb 13, 2014

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
Copy link
Owner

chicks commented Feb 13, 2014

PS, Congrats on being the 100th issue submitter!

@pjsim
Copy link
Author

pjsim commented Feb 13, 2014

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

@pjsim pjsim closed this as completed Feb 13, 2014
@pjsim
Copy link
Author

pjsim commented Feb 14, 2014

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 pjsim reopened this Feb 14, 2014
@pjsim
Copy link
Author

pjsim commented Feb 14, 2014

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

@pjsim
Copy link
Author

pjsim commented Feb 14, 2014

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.

@chicks
Copy link
Owner

chicks commented Feb 15, 2014

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.

@pjsim
Copy link
Author

pjsim commented Feb 16, 2014

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

@andrew2005
Copy link

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!

@chicks
Copy link
Owner

chicks commented Mar 24, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants