How to, Workflow designer

How to create purchase orders from sales order in vtiger for every vendor

A request that every customer using vtiger could do is have possiblity to create purchase orders from sales order, but not only one purchase order, but one for every vendor of product that are part of sales order.

Suppose we have a sales order with following product:

Product 1 – vendor A

Product 2 – vendor B

Product 3 – vendor A

Product 4 – vendor C

Product 5 – vendor C


In this case I need 3 purchase order:

PURCHASE ORDER 1: with product 1 and product 3 from vendor A

PURCHASE ORDER 2: with product 2 from vendor B

PURCHASE ORDER 3: with product 4 and product 5 from vendor C

Of course price of products should be purchase price instead of list price.

Realize this possiblity with our workflow designer module is simply.

Main workflow: loop through products

The main workflow is under Sales Order module and should be like following:

The Main block we use after start block is Loop through product (you can find general info here) that in our case will be set like here:

This block will loop on every product of sales order, passing some info to workflow.

Becouse not all info are available, we will use another block called execute espression with external record, to get missing information:

in this block we search in product module all product that have ID of product that is selected in loop. When we find this product we set some environmental variable to have id of vendor, product name and purchase cost.

Now the following step is verifiy if exist a purchase order related to our sales order (to manage this relation we add a uitype10 field in purchase order that point to sales order) with the vendor of product selected from loop: if exist then we add the product to purchase order, if not exist then we create sales order without product with this vendor set and then we add the product.

The condition should be set as following:


Add product moving data to external workflow

This is a powerful solutlion we used to add product to purchase orders.

We moved some data from main workflow to a secondary workflow using WRITE ENTITY DATA BLOCK.

As you can see in image we set some variables in example idproduct will take values from environmental variable $env[“product”][“productid”] and so on.

Then we call an external workflow:

The workflow is “add product from ODV” and is executed on Purchase order with id found in global search.

The new workflow is like this:

The block READ ENTITY DATA is able to read data written in block WRITE ENTITY DATA:

Last step is to add product to this Purchase order, using data we get:


This workflow could be called with a button in sales order, that allow to automatically create all purchase order:


You can create this workflow and other powerfull workflows using our module:

Workflow Designer


Leave A Comment

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.