简体   繁体   English

如何在动态操作中调用外部 Javascript 函数?

[英]How to call an external Javascript function in a dynamic action?

I have a dynamic action set to trigger when a user presses a button.我有一个动态动作设置为在用户按下按钮时触发。 However I am well above the limit for the JavaScript I can put into the text box.但是,我远远超出了可以放入文本框中的 JavaScript 的限制。 I have uploaded my function as a .js file to the static file shared components part of the application.我已将我的函数作为 .js 文件上传到应用程序的静态文件共享组件部分。

However, I am at a loss as to how to now call that function when the dynamic action triggers.但是,我不知道如何在动态操作触发时调用该函数。 Also my JavaScript relies on form entries on the page it's being called from as it uses that data as variables.此外,我的 JavaScript 依赖于它被调用的页面上的表单条目,因为它使用该数据作为变量。

How can I set the page to be able to call the function from the external .js file?如何将页面设置为能够从外部 .js 文件调用该函数? Preferably in as step-by-step fashion as possible as I am still very new to Apex.最好以尽可能循序渐进的方式进行,因为我对 Apex 还很陌生。

You did well to add it to the static files, but you have to tell your app that you have an external js file.您将它添加到静态文件中做得很好,但是您必须告诉您的应用您有一个外部 js 文件。

There are two options to do this:有两种选择可以做到这一点:

  1. In the page properties if you are only going to use the function on that page.如果您只打算在该页面上使用该功能,请在页面属性中。 Editing the javascript File URLs option编辑 javascript 文件 URL 选项

在此处输入图片说明

  1. In shared Components, in the details of User Interface Attributes.If you are going to use the function throughout the application.在共享组件中,在用户界面属性的详细信息中。如果您打算在整个应用程序中使用该功能。

在此处输入图片说明

After that, simply use your function on the trigger之后,只需在触发器上使用您的功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM