In this post I am going to show you how to make a custom related list. In this case, I’m showing the purchase orders in which a particular product is found. The way to do that is to create an XML document that represents the related list. 

You can find this documentation on the Zoho CRM website. It’s a little bit confusing, but once you get your head around it, it’s pretty easy. This is the basic structure we’re going after. 

We have “<record>” as the overarching tag. For every row, we include a row number and then we include some fields. You’ll notice that it has “val=Name1.”

“Val=Name1” will become the column at the top of the related list and then the value between the triangle brackets will be the value in the row. The highlighted text will be the column name and the text below that is the value. 

In order to generate this, I’ve got a custom function that gets the product record as well as the list of purchase order IDs that the product has been included in. In order to generate that list, I’ve got another workflow that will automatically add the IDs of purchase orders, in which this product is included. That workflow runs every time you create or edit a purchase order.

My purchase order module is not the standard purchase order module. I had to make my own because I needed to have different line item settings in there. 

Here’s the code for the custom function. It gets the purchase order, the line items, and then it goes through each product and gets the ID of the product, looks up that product, gets what is already in the text field “purchase orders involved,” and checks if that list already has the current purchase order ID. If it does have it, it does nothing. If it doesn’t contain it, then it will add it to that list.


That code allows us to extract the product IDs from the purchase order line items subform:


Now we know how to get the data, let’s create a custom related list.

You click on “Add Related List” and then choose “functions.” In this case, I have already got one. 

The function retrieves the purchase order IDs for the product and then splits it into a list by using the “tolist” function. Once we have that list, we retrieve the data for each purchase order. Then we generate the XML for the related list.

One cool thing is that you can make the rows link to a particular record, if you want. You can write out, “link=’true’” and then you provide the URL. 

In this example, my purchase order is, “CustomModule4” and I just need to give the purchase order ID. Again, the “val” will be the column name, and the bit between the XML tags will be the text that appears in the row. You finish up by closing off the record tag and you get this output here. 

You’ll notice that it takes a little bit of time to load because it has to run the custom function, but then you end up with a related list that can contain anything you want.