Start Javascript from Custom Action Button

I want to start a JavaScript from the custom action button.  Right now I'm trying to load my JavaScript file with SP.SOD.executeFunc.

My current link looks like:

javascript: SP.SOD.registerSod('JavaScript', '/SiteAssets/javascript/JavaScript.js'); SP.SOD.executeFunc('JavaScript', null, test());

It fails to load the function test().

It works if I load a standard alert.

javascript: SP.SOD.registerSod('JavaScript', '/SiteAssets/javascript/JavaScript.js'); SP.SOD.executeFunc('JavaScript', null, alert('test'));










javascript: SP.SOD.registerSod('JavaScript', '/SiteAssets/javascript/JavaScript.js'); SP.SOD.executeFunc('JavaScript', test, alert('test'));

July 24th, 2015 2:30pm

Hi,

Please check if it helps you

https://social.technet.microsoft.com/Forums/office/en-US/12a3df95-2ce3-4365-ab0f-2a3ce07f3693/how-do-i-set-a-string-to-xml-in-the-custom-action-button-javascript?forum=sharepointdevelopmentprevious

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 5:04pm

I'm trying to avoid having to build a solution.  I was hoping to use the SOD functions to load the scripts and functions when the button was pressed.
July 24th, 2015 6:25pm

meaning I'd like to run in like

javascript:alert('test'); alert('test2'); alert('test3');

but I was hoping to use SOD, and load my function

I just don't know how to use it.  I see examples on how to do it but it doesn't work how I'm trying to do it.

Free Windows Admin Tool Kit Click here and download it now
July 24th, 2015 6:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics