<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Get link to process of another project</title><link>https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project</link><description>&lt;p&gt;&lt;code&gt;ivy.html.startref&lt;/code&gt; allows me to get a link to another process starts. Unfortunately this only seems to work within the same project.&lt;/p&gt;
&lt;p&gt;Is there any way I can get a link to the process start of another project? Using &lt;code&gt;ivy.html.startref("Projectname/Processname/startName.ivp")&lt;/code&gt; or &lt;code&gt;ivy.html.startref("../Projectname/Processname/startName.ivp")&lt;/code&gt; don't seem to work.&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 21 Oct 2016 04:35:40 -0400</lastBuildDate><item><title>Answer by trungdv</title><link>https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project/2125</link><description>&lt;p&gt;I've tried with above solution with Axon ivy 6.3 , but it throw exception NoSuchElementException on line &lt;em&gt;processStarts.iterator().next() as IProcessStart;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So i tried another one and it works:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; public String getStartUrl(boolean isAbsoluteLink, String startProcessPoint) throws Exception {
     String requestPath = SecurityServiceUtils.findProcessByUserFriendlyRequestPath(startProcessPoint);
        if (isAbsoluteLink) {
          UrlDetector urlDetector = new UrlDetector();
          String serverUrl = urlDetector.getBaseURL(FacesContext.getCurrentInstance());
          return serverUrl + requestPath;
        }
        String language = URLEncoder.encode(Ivy.session().getContentLocale().getLanguage(), "UTF-8");
        return "/" + RequestUriFactory.getIvyContextName(ServerFactory.getServer().getApplicationConfigurationManager())
            + requestPath + "?language=" + language;
      }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And below is SecurityServiceUtils.findProcessByUserFriendlyRequestPath():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public static String findProcessByUserFriendlyRequestPath(String processStartSignature) throws Exception {
return ServerFactory.getServer().getSecurityManager().executeAsSystem(new Callable&amp;lt;String&amp;gt;() {

  @Override
  public String call() throws Exception {
    ProcessStartCollector processStartCollector = new ProcessStartCollector(Ivy.wf().getApplication());
    IProcessStart processStart =
        processStartCollector.findProcessStartByUserFriendlyRequestPath(processStartSignature);
    if (processStart != null) {
      try {
        return "/pro/" + processStart.getFullRequestPath();
      } catch (Exception e) {
        Ivy.log().error(e);
        return StringUtils.EMPTY;
      }
    }
    return StringUtils.EMPTY;
  }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;And the class ProcessStartCollector &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import java.net.MalformedURLException;
import java.net.URI;
import java.util.List;
import java.util.concurrent.Callable;
import javax.faces.context.FacesContext;
import org.apache.commons.lang3.StringUtils;
import ch.ivy.addon.portalkit.support.UrlDetector;
import ch.ivyteam.ivy.application.ActivityState;
import ch.ivyteam.ivy.application.IApplication;
import ch.ivyteam.ivy.application.IProcessModel;
import ch.ivyteam.ivy.application.IProcessModelVersion;
import ch.ivyteam.ivy.environment.Ivy;
import ch.ivyteam.ivy.request.RequestUriFactory;
import ch.ivyteam.ivy.server.ServerFactory;
import ch.ivyteam.ivy.workflow.IProcessStart;
import ch.ivyteam.ivy.workflow.IWorkflowProcessModelVersion;
import ch.ivyteam.ivy.workflow.WorkflowNavigationUtil;

public class ProcessStartCollector {

  private final IApplication application;

  public ProcessStartCollector(IApplication application) {
    this.application = application;
  }

  public IProcessStart findProcessStartByUserFriendlyRequestPath(String requestPath) {
    if (isActive(this.application)) {
      List&amp;lt;IProcessModel&amp;gt; processModels = this.application.getProcessModelsSortedByName();

      for (IProcessModel processModel : processModels) {

        if (isActive(processModel)) {
          IProcessModelVersion processModelVersion = processModel.getReleasedProcessModelVersion();

          if (isActive(processModelVersion)) {
            IWorkflowProcessModelVersion workflowPmv =
                WorkflowNavigationUtil.getWorkflowProcessModelVersion(processModelVersion);
            IProcessStart processStart = workflowPmv.findProcessStartByUserFriendlyRequestPath(requestPath);
            if (processStart != null) {
              return processStart;
            }
          }
        }
      }
    }
    return null;
  }

  public String findACMLink() throws Exception {
    return ServerFactory.getServer().getSecurityManager().executeAsSystem(new Callable&amp;lt;String&amp;gt;() {
      @Override
      public String call() throws Exception {
        ProcessStartCollector collector = new ProcessStartCollector(application);
        IProcessStart process =
            collector.findProcessStartByUserFriendlyRequestPath("BusinessProcesses/AdHocWF/start.ivp");
        if (process != null) {
          URI processUri =
              RequestUriFactory.createProcessStartUri(ServerFactory.getServer().getApplicationConfigurationManager(),
                  process);
          return getServerUrl() + processUri.toString();
        }
        return StringUtils.EMPTY;
      }
    });
  }

  private String getServerUrl() {
    UrlDetector urlDetector = new UrlDetector();
    String serverUrl = StringUtils.EMPTY;
    try {
      String baseUrl = urlDetector.getBaseURL(FacesContext.getCurrentInstance());
      serverUrl = urlDetector.getHost(baseUrl);
    } catch (MalformedURLException e) {
      Ivy.log().error(e);
    }
    return serverUrl;
  }

  private boolean isActive(IProcessModelVersion processModelVersion) {
    return processModelVersion != null &amp;amp;&amp;amp; ActivityState.ACTIVE.equals(processModelVersion.getActivityState());
  }

  private boolean isActive(IProcessModel processModel) {
    return ActivityState.ACTIVE.equals(processModel.getActivityState());
  }

  private boolean isActive(IApplication application) {
    return ActivityState.ACTIVE.equals(application.getActivityState());
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hope it's helpful&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">trungdv</dc:creator><pubDate>Fri, 21 Oct 2016 04:35:40 -0400</pubDate><guid>https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project/2125</guid></item><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project/1063</link><description>&lt;p&gt;The &lt;code&gt;ivy.html.startref&lt;/code&gt; only works for process starts that are in the same project as the callee. If you want to get a link to a process starts that is outside of your project you can use the following ivyScript snippet:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.ivy.request.IHttpRequest;
import java.util.Set;
import ch.ivyteam.ivy.workflow.IProcessStart;

if (ivy.request instanceof IHttpRequest)
{
    Set processStarts = ivy.wf.findProcessStartsBySignature("myProcessStart()");
  IProcessStart processStart = processStarts.iterator().next() as IProcessStart;
  String fullRequestPath = processStart.getFullRequestPath();
    IHttpRequest httpRequest = ivy.request as IHttpRequest;
    String requestUri = httpRequest.getHttpServletRequest().getContextPath() + "/process/"+fullRequestPath;
}
&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Fri, 28 Nov 2014 13:40:00 -0500</pubDate><guid>https://answers.axonivy.com/questions/1061/get-link-to-process-of-another-project/1063</guid></item></channel></rss>