Error Message: 

Error while creating new document. Error message: Didn’t understand relationship ‘LineItemCount’ in field path. If you are attempting to use a custom relationship, be sure to append the ‘__r’ after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.”

-You may receive an error like this when generating document and you are seeing the red bar with error message.

How to resolve:
You can normally see which field it is referring too so you know what to focus on. In this case, it is “line item count.” Try to find the error message on your template that is referring to this field, remove it from template and then generate document once again. If there is no error message then you know that is the field you need to fix.

Usually an error message that refers to append the ‘_r” is referring to a related list item in your template that is coming from child object merge field list. You may be using the incorrect merge field so try to navigate through template builder to find the correct merge field though through another relationship path (may need to go through Object Line Items, then find the object ID > then merge field name). You can copy/paste multiple field options onto your template for which you might think is correct one and then test it, see which one works. It may take some trial and error to find the right field. Remember that any merge field from related list/child object needs to be placed inside of a table so the rows repeat themselves. 

If you find that one user gets an error message when generating document and another user (maybe system admin type) does not get error message, then you know it is an issue with object or field permissions. You can see this article for more information on permissions.