<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Status code of a webapi to start process model</title><link>https://community.appian.com/discussions/f/process/20396/status-code-of-a-webapi-to-start-process-model</link><description>Hi, 
 I have a webapi created in appian that starts a process model, it always returns a 200 status code because starting the process correctly, but this process can fail. 
 Is there any way that this webapi does not return statusCode 200 if the process</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Status code of a webapi to start process model</title><link>https://community.appian.com/thread/89463?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 15:11:19 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6bc714a0-f28e-4e0f-98e6-feb149386257</guid><dc:creator>Rituraj Jain</dc:creator><description>&lt;p&gt;Updated link -&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/21.4/Process_Model_Recipes.html"&gt;https://docs.appian.com/suite/help/21.4/Process_Model_Recipes.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Section &amp;quot;Breaking a Chain&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Status code of a webapi to start process model</title><link>https://community.appian.com/thread/79555?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 14:27:27 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:53bfe5fb-bc4b-4071-b93a-85aa78c3b6a7</guid><dc:creator>Danny Verb</dc:creator><description>&lt;p&gt;Here are the docs for breaking a chain&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/17.4/Configuring_Activity-Chaining.html#breaking-a-chain"&gt;https://docs.appian.com/suite/help/17.4/Configuring_Activity-Chaining.html#breaking-a-chain&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You are able to chain into a sub-process as long as all the nodes you need are also chained and you set the correct settings on the sub-process node. A user task is expected because a user could sit on that task for days which means your REST call would time out well before that.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If these still don&amp;#39;t meet your use case, you might want to look into setting up some kind of callback where Appian can call your service after the process completes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Status code of a webapi to start process model</title><link>https://community.appian.com/thread/79552?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 12:47:47 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:12c528bc-78f2-4ffe-9aec-78b094c53c2e</guid><dc:creator>salehc0001</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;div&gt;I&amp;#39;ve tried with activity chaining but it seems that calling subprocesses or assigning tasks break that chain and sends the response right away. In this case, how can i delay the response until the process ends?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Thanks.&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Status code of a webapi to start process model</title><link>https://community.appian.com/thread/79531?ContentTypeID=1</link><pubDate>Fri, 12 Feb 2021 17:52:40 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2de107ba-d451-4593-b816-f39dde4c721f</guid><dc:creator>Danny Verb</dc:creator><description>&lt;p&gt;If you used the template for starting a process model via webapi you&amp;#39;ll see that the onSuccess parameter is&amp;nbsp;evaluated when the process kicks off successfully. However, the onSuccess also won&amp;#39;t evaluate until the chain completes within a process. What this allows you to do is chain a number of nodes together starting with the beginning of your process model and at certain points update a process variable with the progress. Then using the function variable fv!processInfo you&amp;#39;ll be able to use the values of these process variables in the onSuccess parameter. Documentation is here&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/20.4/Start_Process_Smart_Service.html#a!startprocess()"&gt;https://docs.appian.com/suite/help/20.4/Start_Process_Smart_Service.html#a!startprocess()&lt;/a&gt;. Using those variables you can return different status codes.&lt;/p&gt;
&lt;p&gt;Please remember that by chaining your process this will cause Appian to prioritize executing those nodes. Also, if you have a lot of nodes this means your webapi request time will be slower.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Does this help?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="java"&gt;a!startProcess(
  processModel: cons!PROCESS_MODEL,
  processParameters: a!fromJson(
    http!request.body
  ),
  onSuccess: {
    if(
        fv!processInfo.pv.finishedAllNodes,
        a!httpResponse(
            statusCode: 200,
            headers: {
              a!httpHeader(name: &amp;quot;Content-Type&amp;quot;, value: &amp;quot;application/json&amp;quot;)
            },
            body: a!toJson(
              fv!processInfo
            )
         ),
         a!httpResponse(
            statusCode: 205,
            headers: {
              a!httpHeader(name: &amp;quot;Content-Type&amp;quot;, value: &amp;quot;application/json&amp;quot;)
            },
            body: a!toJson(
              {
                error: &amp;quot;Process started but not all nodes completed successfully&amp;quot;
              }
            )
          )
    )
  },
  onError: a!httpResponse(
    statusCode: 500,
    headers: {
      a!httpHeader(name: &amp;quot;Content-Type&amp;quot;, value: &amp;quot;application/json&amp;quot;)
    },
    body: a!toJson(
      {
        error: &amp;quot;There was an error starting the process&amp;quot;
      }
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>