cancel
Showing results for 
Search instead for 
Did you mean: 

Create site by workflow

adhi27
Champ in-the-making
Champ in-the-making
i want create site automatic when workflow task done, is it possible or not to do that?
and is possible how i can do that?

sorry my english so bad
9 REPLIES 9

darkredd
Star Contributor
Star Contributor
Hi,

It is possible to do that, in your complete task on the workflow; have a script that uses the Site service API to create the site. Study how the site service API works before attempting to incorporate with the workflow.

But why would you want to create a SITE each time a workflow is complete???

adhi27
Champ in-the-making
Champ in-the-making
thanks you darkRedd

no but when task 1 is task done so automatic script create SITE workflow and can u give me a example script to create site in workflow

thanks

darkredd
Star Contributor
Star Contributor
Hi,

Go through this http://docs.alfresco.com/5.1/references/API-JS-SiteService-createSite.html and you should be able to create a site after this.

adhi27
Champ in-the-making
Champ in-the-making
thanks you DarkRedd but when i try that code i have error when i in site create by script
sorry bad english

darkredd
Star Contributor
Star Contributor
Hi,

Post the script you are using to create the site with.

adhi27
Champ in-the-making
Champ in-the-making
var site = siteService.createSite("site-dashboard", "gamma-site", "Gamma Site", "A site description", siteService.PUBLIC_SITE);     

niketapatel
Star Contributor
Star Contributor
This will only create a site folder structure in Explorer/Repository. So it wont be fully functional site.
You also need to create surf object for Share side configurations like dashboard preset.

Please check OOB Share side webscipt - /share/page/script/org/alfresco/modules/create-site.post

adhi27
Champ in-the-making
Champ in-the-making
niketapatel thanks for your replay

how i create that surf for create Site??

sorry bad english

adhi27
Champ in-the-making
Champ in-the-making
this is - /share/page/script/org/alfresco/modules/create-site.post
File: org/alfresco/modules/create-site.post.desc.xml

<webscript>
   <shortname>Create Site Module Repository Call</shortname>
   <description>
      Will redirect post to the repo to create the site in the repo
      and then create the preset in the web tier.
   </description>
   <format default="json"/>
   <url>/modules/create-site</url>
</webscript>

File: org/alfresco/modules/create-site.post.json.ftl

{
   "success": ${success?string}
<#if code?exists>, "code": ${code}</#if>
<#if error?exists>, "error": "${error}"</#if>
}

File: org/alfresco/modules/create-site.post.json.js

function main()
{
   model.success = false;
  
   // Get clients json request as a "normal" js object literal
   var clientRequest = json.toString();
   var clientJSON = eval('(' + clientRequest + ')');
  
   // Call the repo to create the site
   var scriptRemoteConnector = remote.connect("alfresco");
   var repoResponse = scriptRemoteConnector.post("/api/sites", clientRequest, "application/json");
   if (repoResponse.status == 401)
   {
      status.setCode(repoResponse.status, "error.loggedOut");
   }
   else
   {
      var repoJSON = eval('(' + repoResponse + ')');
     
      // Check if we got a positive result
      if (repoJSON.shortName)
      {
         // Yes we did, now create the site in the webtier
         var tokens = [];
         tokens["siteid"] = repoJSON.shortName;
         sitedata.newPreset(clientJSON.sitePreset, tokens);
         model.success = true;
      }
      else if (repoJSON.status.code)
      {
         // Default error handler
         status.setCode(repoJSON.status.code, repoJSON.message);
      }
   }
}

main();

Store: classpath:surf/webscripts

[No implementation files]

Store: classpath:webscripts

[No implementation files]