Change layout of aspx page using site script

%3CLINGO-SUB%20id%3D%22lingo-sub-1947457%22%20slang%3D%22de-DE%22%3EChange%20layout%20of%20aspx%20page%20using%20site%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1947457%22%20slang%3D%22de-DE%22%3E%3CP%3EWe%20want%20to%20enable%20our%20teams%2C%20to%20have%20a%20choice%20of%20which%20predefined%20page%20layout%20they%20can%20choose.%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20change%20the%20site%20layout%20(arrange%20webparts%20on%20the%20aspx%20page)%20using%20SharePoint%20site%20scripting%3F%20If%20not%2C%20what%20do%20you%20think%20could%20be%20an%20alternative%20operation%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1947457%22%20slang%3D%22de-DE%22%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1948031%22%20slang%3D%22de-DE%22%3ESubject%3A%20Change%20layout%20of%20aspx%20page%20using%20site%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1948031%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F888070%22%20target%3D%22_blank%22%3E%40Br_Joe%3C%2FA%3E%20to%20change%20web%20parts%20you%20don't%20need%20a%20script.%20First%20question%3A%20What%20SharePoint%20version%20is%20it%20you%20are%20in%3F%20Classic%20SharePoint%20Site%20or%20Modern%20SharePoint%20Site%3F%20And%20you%20should%20avoid%20site%20scripts%20which%20inserted%20once%20in%20classic%20SharePoint%202013%20Sites%2C%20and%20there%20was%20a%20Script%20Editor%20Webpart%20then.%20Those%20where%20the%20days...%20%3A)%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20your%20admin%20still%20alows%20you%20to%20take%20those%20old%20and%20outdated%20webparts%2C%20you%20should%20be%20aware%20that%20in%20modern%20sites%20you%20don't%20have%20to%20script%20webparts%20anymore.%20The%20new%20code%20behind%20your%20aspx%20Web%20Pages%20is%20javascript%2C%20not%20xml.%20And%20we%20are%20still%20in%20some%20areas%20working%20the%20old%20pages%20but%20we%20should%20not%20engage%20again%20with%20scripts.%20To%20change%20webparts%20you%20just%20should%20edit%20a%20page%20and%20in%20this%20edit%20mode%20you%20can%20arrange%20webparts%2C%20add%20webparts%20and%20change%20their%20behavior%20with%20the%20pencil%20icon.%20If%20you%20need%20some%20special%20user-defined%20manipulation%2C%20you%20can%20use%20javascript%20schemas%20and%20there%20are%20tons%20of%20javascript%20examples%20on%20it%2C%20on%20github.com.%20For%20instance%20the%20conditional%20formatting%20and%20other%20developping%20stuff%20on%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ESharePoint%20Development%20documentation%20%7C%20Microsoft%20Docs%3C%2FA%3E%3C%2FP%3E%3CP%3EI%20hope%20that%20helps%20and%20give%20a%20LIKE%20if%20so.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20not%2C%20just%20pls.%20give%20more%20information%20of%20what%20you%20are%20trying%20to%20realize%20with%20your%20pages%20or%20%2F%20and%20webparts.%20I%20am%20sure%2C%20there%20is%20already%20a%20webpart%20in%20modern%20SharePoint%20that%20will%20satisfy%20your%20needs%20within%20your%20pages%20(modern%20ones)...%3C%2FP%3E%3CP%3Ehave%20a%20good%20day%2C%3C%2FP%3E%3CP%3ECheers%3C%2FP%3E%3CP%3EEva%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

We want to enable our teams, to have a choice of which predefined page layout they can choose.

Is there a way, to change the site layout (arrange webparts on the aspx page) using SharePoint site scripting? If not, what do you think could be an alternative operation?

 

2 Replies

@Br_Joe  to change Webparts you don't need a script. First question: What SharePoint Version is it you are in? Classic SharePoint Site or Modern SharePoint Site? And you should avoid site scripts which where inserted once in classic SharePoint 2013 Sites, and there was a Script Editor Webpart then. Those where the days... :) 

If your Admin still alows you to take those old and outdated Webparts, you should be aware that in modern Sites you don´t have to script webparts anymore. The new code behind your aspx Web Pages is javascript, not xml. And we are still in some areas working the old pages but we should not engage again with scripts. To change webparts you just should edit a page and in this edit mode you can arrange webparts, add webparts and change their behaviour with the pencil icon. If you need some special user-defined manipulation, you can use javascript schemas and there are tons of javascript examples on it, on github.com. For instance the conditional formatting and other developping stuff on SharePoint Development documentation | Microsoft Docs

I hope that helps and give a LIKE if so.

 

If not, just pls. give more information of what you are trying to realize with your  pages or / and webparts. I am sure, there is already a webpart in modern SharePoint that will satisfy your needs within your pages (modern ones)...

have a good day, 

Cheers,

Eva

 

@Eva Vogel thanks for your detailed reply.

We are working with SharePoint online and the Modern Sites.

We are generating new SharePoint Sites from Power Automate for our sales teams. The different teams have different requirements, how a starting page for a customer should look like (but only in the layout of the webparts or apps). We want to give a choice which starting page they can use for their team (in Power Automate) and set the layout (arrangement of webparts) automatically. Our first thought was to use Site Scripting but as far as I read this is not possible with Site scritpting.  As this feature is very important for our sales teams we additionally are looking for alternative methods. We just want to avoid the manually arrangement of webparts  respectively don't want our sales teams to do so. So there is no background programming, it is just the automated arrangement of webparts.

 

Cheers

Jörg