I have an on site implementation (Sugar Ent 10.0.3) and I have an external process on the CRON server that creates pdf files that I have to relate to Contact Records.
Hi Pedro Bazan,
I haven't seen you for a while, good to have you back.
While Dmytro's solution may very well be the fastest way to do this, it does require you purchasing the Logic Builder tool he is selling.
I have not worked with AWS S3, but within the Sugar Framework, I have a snippet of code that still works but was developed back in 2012 and might need some updating... still, it may give some useful clues...
This old code takes a file that a user uploaded in a web form and creates a record in a custom module called attch_CaseAttachments which is a "Documents" type module related to Cases. The file that was uploaded is stored in the upload directory specified in your SugarCRM's config file upload_dir:
//HANDLE ANY ATTACHMENTS if(isset($_FILES['attachment']) && $_FILES['attachment']['error'] != '0'){ $errMsg = string_format($GLOBALS['app_strings']['UPLOAD_ERROR_TEXT'],array($_FILES['attachment']['error'], self::$AttachmentError[$_FILES['attachment']['error']])); $GLOBALS['log']->debug("WebForm:: Attachment ERROR {$errMsg}"); exit_with_message(true, $AttachmentError[$_FILES['attachment']['error']]); }elseif(isset($_FILES['attachment']) && $_FILES['attachment']['error'] == '0'){ $uf = new UploadFile('attachment'); if($uf->confirm_upload()){ $GLOBALS['log']->debug("WebForm:: Processing Attachment:" . print_r($uf,true)); $do_final_move = false; $a = BeanFactory::newBean('attch_CaseAttachments'); $doc_name = isset($input['attachmentName'])?$input['attachmentName']:$uf->stored_file_name; $a->filename = $doc_name; $a->document_name = $doc_name; $a->file_mime_type = $uf->mime_type; $a->category_id = 'incoming'; $a->team_id = $team_id; $a->team_set_id = $team_set_id; $a->save(); $attach_id = $a->id; $do_final_move = true; if ($do_final_move) $uf->final_move($attach_id); }else{ $GLOBALS['log']->debug("WebForm:: Could not Process Attachment"); } } $cs = BeanFactory::retrieveBean('Cases', $case_id, array('use_cache' => false)); // link the case to the attachment if (isset($attach_id) && $attach_id != ''){ $GLOBALS['log']->debug("WebForm::[CASE:{$case_number}] Link Attachment to Case"); $cs->load_relationship('attch_caseattachments_cases'); $cs->attch_caseattachments_cases->add($attach_id); }
See if it helps :)
FrancescaS
Hi Pedro Bazan,
I haven't seen you for a while, good to have you back.
While Dmytro's solution may very well be the fastest way to do this, it does require you purchasing the Logic Builder tool he is selling.
I have not worked with AWS S3, but within the Sugar Framework, I have a snippet of code that still works but was developed back in 2012 and might need some updating... still, it may give some useful clues...
This old code takes a file that a user uploaded in a web form and creates a record in a custom module called attch_CaseAttachments which is a "Documents" type module related to Cases. The file that was uploaded is stored in the upload directory specified in your SugarCRM's config file upload_dir:
//HANDLE ANY ATTACHMENTS if(isset($_FILES['attachment']) && $_FILES['attachment']['error'] != '0'){ $errMsg = string_format($GLOBALS['app_strings']['UPLOAD_ERROR_TEXT'],array($_FILES['attachment']['error'], self::$AttachmentError[$_FILES['attachment']['error']])); $GLOBALS['log']->debug("WebForm:: Attachment ERROR {$errMsg}"); exit_with_message(true, $AttachmentError[$_FILES['attachment']['error']]); }elseif(isset($_FILES['attachment']) && $_FILES['attachment']['error'] == '0'){ $uf = new UploadFile('attachment'); if($uf->confirm_upload()){ $GLOBALS['log']->debug("WebForm:: Processing Attachment:" . print_r($uf,true)); $do_final_move = false; $a = BeanFactory::newBean('attch_CaseAttachments'); $doc_name = isset($input['attachmentName'])?$input['attachmentName']:$uf->stored_file_name; $a->filename = $doc_name; $a->document_name = $doc_name; $a->file_mime_type = $uf->mime_type; $a->category_id = 'incoming'; $a->team_id = $team_id; $a->team_set_id = $team_set_id; $a->save(); $attach_id = $a->id; $do_final_move = true; if ($do_final_move) $uf->final_move($attach_id); }else{ $GLOBALS['log']->debug("WebForm:: Could not Process Attachment"); } } $cs = BeanFactory::retrieveBean('Cases', $case_id, array('use_cache' => false)); // link the case to the attachment if (isset($attach_id) && $attach_id != ''){ $GLOBALS['log']->debug("WebForm::[CASE:{$case_number}] Link Attachment to Case"); $cs->load_relationship('attch_caseattachments_cases'); $cs->attch_caseattachments_cases->add($attach_id); }
See if it helps :)
FrancescaS
Hi Francesca,
Yes, I do promote the Logic Builder - a cloud tool https://logicbuilder.integroscrm.com
For the annual Logic Builder subscription cost for the company, which amount is less than 3 days of Professional IT Services according to the regular US/UK/EU rates, it enables deep Sugar platform capabilities and rapid Sugar configuring of numerous customer tasks for techies of Sugar admin-level - those, who usually cover the gaps to unique company demands with Studio, SugarBPM, Advanced Reporting and sometimes forced to build crazy unary operation formulas for calc fields
Regardin AWS topic - most of AWS services are reachable via the low-code tool - not just S3 bucket, but also Rekognition, Comprehend, Transcribe, etc letting the platform do the work in interests of Sugar subscribers
Please note - any of the configurations performed are installable via Module Loader and do not demand access to Logic Builder environment to operate
And there is neither fee nor bank card needed for the trial
Best Regards,
Dmytro Chupylka
integroscrm.com
We make work in Sugar CRM system faster, more convenient and efficient