Mayan EDMS Index Reference

Community contributed guides or tutorials for multiple topics like installations for other operating systems or platforms, monitoring, log aggregation, etc.
taro
Posts: 0
Joined: Mon May 25, 2020 7:13 am

Re: Mayan EDMS Index Reference

Post by taro »

Hi all,

I'm quite new to Mayan and I'm trying to learn how to use this wonderful index features. I have a question about adding child node. Below is what I want to do:

1. Any document comes in will have invoice number as custom metadata.

2. The first level of the child node will check the first character of the invoice number and set an index for it. For example:

{% if document.metadata_value_of.invoice_number.0 == "A" %}Accounting
{% elif document.metadata_value_of.invoice_number.0 == "H" %}Human Resources
{% endif %}

3. Then, I add another child node under number 2 above (this new node is the child of either "Accounting" or Human Resources"). I want to add the condition to this node like:

{% if document.metadata_value_of.invoice_number|slice:"1:3"== "NE" %}New Employee
{% elif document.metadata_value_of.invoice_number|slice:"1:3" == "CT" %}Contract
{% endif %}

However, it seems that the condition doesn't work at all on number 3. I tried to remove all if/else and make the template like:

document.metadata_value_of.invoice_number|slice:"1:3"

And it works. Can anyone let me know if there is no way we can get condition work on child node of another child node?
mattwebboz
Posts: 0
Joined: Sat Oct 03, 2020 10:45 am

Re: Mayan EDMS index reference post

Post by mattwebboz »

monadnock wrote:
> Is there a way to view Django template errors or get some troubleshooting
> output when index templates fail to produce the desired results? They
> aren't in the docker logs output and I cannot find them in the menus...
>
> It's very frustrating to play "guess the problem" with a
> moderately complex index template.
>
> Example:
> [code]
> {% if document.metadata_value_of.date_issued %}
>
> {% if document.metadata_value_of.date_issued|slice:"5:7" in
> '10,11,12' %}
> FY{{
> document.metadata_value_of.date_issued|slice:":4"|add:"1"
> }}
> {% elif document.metadata_value_of.date_issued|slice:"5:7"
> in '01,02,03,04,05,06,07,08,09' %}
> FY{{ document.metadata_value_of.date_issued|slice:":4" }}
>
> {% else %}
>
> Unknown
>
> {% endif %}
>
> {% elif document.file_metadata_value_of.ModifyDate %}
>
> {% if document.file_metadata_value_of.ModifyDate|slice:"5:7"
> in '10,11,12' %}
> FY{{
> document.file_metadata_value_of.exiftool_ModifyDate|slice:":4"|add:"1"
> }}
> {% elif
> document.file_metadata_value_of.exiftool_ModifyDate|slice:"5:7"
> in '01,02,03,04,05,06,07,08,09' %}
> FY{{
> document.file_metadata_value_of.exiftool_ModifyDate|slice:":4" }}
>
> {% else %}
>
> Unknown
>
> {% endif %}
>
> {% else %}
>
> Unknown
>
> {% endif %}
> [/code]
>
> Fairly straight forward fiscal year calculation (possibly from metadata
> *or* file metadata). Produces no documents, but it's not possible to tell
> why. If there's no errors in the template, then at worst all the documents
> should show up under "Unknown"...
>
> Is there a better way to test for the existance of optional metadata? Is
> there another template problem? It's very difficult to track down these
> sorts of issues.
Hey - don't have an answer regarding debugging, but using your example, I was able to create a Financial Year index. I've included it here in anyone finds it useful:

{% if document.metadata_value_of.TransactionDate|slice:"5:7" in '07,08,09,10,11,12' %}
FY{{ document.metadata_value_of.TransactionDate|slice:"0:4"|add:"1" }}
{% elif document.metadata_value_of.TransactionDate|slice:"5:7" in '01,02,03,04,05,06' %}
FY{{ document.metadata_value_of.TransactionDate|slice:"0:4"|add:"0"}}
{% else %}
No Tr Date
{% endif %}

Cheers,
Matt.
Post Reply