Customizing doctypes: How to add a preview depending on another field

Hi everyone,

this time I have another question regarding doctype customizing (using v14):

I have created a simple custom doctype “Invoice Intro Text” which consists out of only 2 fields:

  • intro_name (data)
  • intro_text (short text)

I did manage to create an additional custom field with a link to the doctype inside the sales invoice form:

  • Name: invoice_intro_text
  • Type: link
  • Options: Invoice Intro Text
  • Fetch from: intro_text

For some reason this field is showing always the naming series after the selection.
So I decided to add another field that just displays the actual text to me:

  • Name: intro_text_preview
  • Type: link
  • Options: Invoice Intro Text
  • Fetch from: invoice_intro_text.intro_text
  • Depending on: invoice_intro_text
    and I checked the box in front of “preview”

When I’m coming back to the invoice form now the second field appears aswell after I made a selection like I intended it and it even shows the intro_text that I selected.
Unfortunately after this change I’m not able to save the form anymore - I always do get the message

intro_text_preview: text: couldn’t be found.

I guess that I did make a mistake somewhere, but I can’t figure it out where…
Both options getting the intro_text shown inside the first field instead of the naming series or getting the preview field to work and a saveable state would be totaly fine for me.

Thanks in advance!

Solution for those who might have the same or a similar problem:

Nearly everything was already correct, but instead of another link field you have to set the field type to the actual data type of the value you want to display (in my case short text).
So the correct configuration is:

  • Name: intro_text_preview
  • Type: short text
  • Options: Invoice Intro Text
  • Fetch from: invoice_intro_text.intro_text
  • Depending on: invoice_intro_text
    and I checked the box in front of “preview”
1 Like