Global script basis

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Alex
Posts: 32
Joined: Fri Jun 30, 2017

30 Jun 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

03 Jul 2017

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 3201 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.
Cheers

Alex
Posts: 32
Joined: Fri Jun 30, 2017

04 Jul 2017

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 3197 times
br, Alex

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

04 Jul 2017

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 3194 times
Cheers

Alex
Posts: 32
Joined: Fri Jun 30, 2017

04 Jul 2017

It's 3.1.4
br, Alex

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

04 Jul 2017

Okay, we'll need more information to determine the cause of this.

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

Alex
Posts: 32
Joined: Fri Jun 30, 2017

05 Jul 2017

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

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

05 Jul 2017

Okay, let us know if you have any trouble again.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests