Page 1 of 1

Global script basis

Posted: 30 Jun 2017
by Alex
Hi,
I want to use the same form definition on multiple sites. Therefore it is necessary to keep all scripts in a single file (globally) to keep the maintenance easy.

I tried to use a HTML snippet with the path to the script file, but still get some error messages. Especially if I try to use fd. object selector.
What is the best way to do so (I'm on SharePoint Online)?
br, Alex

Re: Global script basis

Posted: 03 Jul 2017
by Nikita Kurguzov
Hello, Alex!

It should work the way you tried, by imbedding <script src=""></script> into the the HTML element on the form.
Please make sure you imbed HTML snippet into an HTML element, not in JS code or somewhere else.
Html.jpg
Html.jpg (35.08 KiB) Viewed 3206 times
Other than that, you can try running this simple code in a separate file from a form and tell us the results:

Code: Select all

alert(fd.field('Title').value());
It might take a few seconds for a form to update, but if there are still errors, screenshots might help us determine what exactly goes wrong.

Re: Global script basis

Posted: 04 Jul 2017
by Alex
Hi Nikita, I have sometimes an issue that my scripts are running before the fd object is ready.
I think I have to wait until the core Form Designer script is loaded. Could you tell me which one I have to wait for?
I also get messages like this:
2017-07-04_08h04_47.png
2017-07-04_08h04_47.png (23.13 KiB) Viewed 3202 times
br, Alex

Re: Global script basis

Posted: 04 Jul 2017
by Nikita Kurguzov
That's strange, because fd should be initialized by the time any of the elements load, including HTML element.

Can you tell us your version of the Forms Designer? You can check it in the bottom right corner of the app:
VersionNumber.png
VersionNumber.png (2.97 KiB) Viewed 3199 times

Re: Global script basis

Posted: 04 Jul 2017
by Alex
It's 3.1.4
br, Alex

Re: Global script basis

Posted: 04 Jul 2017
by Nikita Kurguzov
Okay, we'll need more information to determine the cause of this.

Can you provide us your brower's full console log?

Re: Global script basis

Posted: 05 Jul 2017
by Alex
It seems to be a special message by Chrome. Other browsers are not showing this.
I think we can close this topic.
br, Alex

Re: Global script basis

Posted: 05 Jul 2017
by Nikita Kurguzov
Okay, let us know if you have any trouble again.