Publishing All Projects using Script

Hello!!!

Sometimes we need to publish all projects from our customers.

We have some options to do that, one of them is using script

In my case, I’ve published using the Project Names, but you can do using other fields, just adjust the script.

Remember, when you run this script, all items will go to the Project Online queue.

Var names = ['project name 1',  //ALWAYS LOWER CASE
             'project name 2',
             'project name 3']

var pp;
$.getScript('https://static.sharepointonline.com/bld/_layouts/15/16.0.6413.1208/ps.js').then(function(){
console.log('1');
var context = PS.ProjectContext.get_current();
var pjs = context.get_projects();
context.load(pjs, 'Include(Id,Name)');
context.executeQueryAsync(function(){
console.log('2');
var it = pjs.getEnumerator()
while(it.moveNext()){
  var p = it.current;
 if(names.indexOf(p.get_name().toLocaleLowerCase()) >= 0)
  {
      console.log('Publishing:'+p.get_name());
      var draft = p.checkOut();
      draft.publish(true);
      context.executeQueryAsync(function(){'done:'+p.get_name()});
  }
}
});
});

Now, connect to your Project Online, open the project center, press “F12” to open the developer tools page and run the script.

I hope it helps you!!!

The script is provided “As is” with no warranties etc. – this is just a free solution starter so is use at your own risk.

#ProActive  #JoinUs

Diego Pereira

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog do Project

Tudo que você queria saber sobre Microsoft Project, Project Server e Project Online

ppm4all

by Allan Rocha

Paul's Project Server and Project Online Blog

Microsoft Project Server and Project Online (PPM)

%d bloggers like this: