SugarCRM:在没有 SOAP 的情况下创建带附件的注释?
我在 Lead Editview 上有一个自定义按钮,单击该按钮会生成(通过 AJAX)发票编号和具有相同编号的 PDF。
在下一步中,例程使用 SOAP 环回 Sugar 并创建一个注释(以及作为附件的 PDF)。
我的问题是我可以避免这个 SOAP 调用并使用其他一些内部机制/类来执行相同的操作吗?类似于
$invoice = new Note();
$invoice->create(....);
...
这可能吗?我在任何地方都找不到任何文档...所有道路似乎都指向 SOAP。
I've got this custom button on Lead Editview that when clicked on generates (via AJAX) an invoice number and a PDF bearing the same number.
In the next step, the routine uses SOAP to loopback to Sugar and creates a Note (along with the PDF as attachment).
My question is can I avoid this SOAP call and use some other internal mechanism / classes to do the same? Something along the lines of
$invoice = new Note();
$invoice->create(....);
...
Is this possible? I couldn't find any documentation anywhere... all roads seem to point to SOAP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的 Ajax 调用正在执行数据库更新/保存操作,那么您可以考虑使用
after_save
逻辑挂钩。编辑:例如:您可以尝试此代码,看看
/modules/Notes/Note.php
中的代码至附件为止,有点棘手。 Sugar 期望附件是 upload_file 对象。查看/include/upload_file 中的代码.php
/modules/Notes/controller.php
函数action_save()
和HACK:这不是正确的方法,但它有效。通过对上面的代码稍作修改并巧妙地使用
move
函数,您就可以使附件正常工作。 Sugar 将附件与创建的笔记 ID 一起存储在cache/upload
文件夹中。HTH
PS:未经测试的代码
If your Ajax call is performing a db update/save operation, then you could look into using a
after_save
logic hook.EDIT: for eg: you could try out this code, have a look at the code in
<sugar_root>/modules/Notes/Note.php
As far as attachment goes, it's a bit tricky. Sugar expects the attachment to be a upload_file object. Have a look at the code in
<sugar_root>/modules/Notes/controller.php
the functionaction_save()
and<sugar_root>/include/upload_file.php
HACK: this is not the correct way but it works. With a slight modification to the code above and cunning use of the
move
function , you could make the attachment work. Sugar stores the attachments incache/upload
folder with the ID of the note created.HTH
P.S: untested code
在controller.php上执行此操作
,这是保存带有附件的注释的功能:
Do this on controller.php
And this is the function to save Notes with attachment: