Hi @ll,
just new here … and maybe not able to search on the correct way (coz of my limited English knowledge)?
I just want to add a tab to the Employee overview. In that tab I want to see all contracts for that employee … and I’m missing the information howto to display all contracts automatically … I already added a link table … and I could choose every contract, one by one and save it … but I would like that all contracts are automatically appears.
Could someone let me know where I can find documentation about how to do that … or maybe give me a short overview how to deal with that issue (it sounds for me like an easy/basic thing … but as mentioned, don’t know for what I have to search for)
Option 4. Doctype Contracts as a separated Doctype (no child table). Customize Employee form with a child table, and create a client script that populates this table with data from Contracts Doctype.
@avc ,
many thanks for your Feedback … one quick question to that …
there is already a “Contract” list available in ERPNext, I just want to use that already existent “thing”, is your option 2 or/and 3 based on the existing contracts or do I create a new kind of “contracts” with that?
I ask … coz until now I tried different ways with linked fields/tables … which are already displaying the contracts, but as mentioned in my first message … not automatically listed, I have to add them all, one by one … instead to just get them all listed … and also that feels like “double” saving … coz the contracts are already in the contract table, why I have to choose and save them again in the “new” self created “employee-contract” table … so I believe I miss some basic understanding about showing/displaying related lists …
Ok, I understand. Yes, Contract doctype can be related with employee as well.
To get tables into forms you need to use “Child tables”. In this case, Contract doctype is not created as child table … so, you can’t “link” it directly.
This is just one way to get what you want. Here we go:
Create doctype named Employee Contract, using this fields info. This doctype is not designed to store data, just for load and show in form. Use “Is Child Table”.
Note: You should consider create an app and store on it all the customization. It’s not recommended to directly editing the doctype, because you will lost your changes with upgrading ERPNext. Use customize form instead.
You can improve this method, adding an action button in each row to open contracts from the table. Right now, if you click on contract id, an open dialog will be opened on “read mode” (using secondary button on mouse you can open in other tab …)
I tried to follow your description step by step … (hopefully I didn’t miss anything!) … but at the end the table is not displayed
A few things …
I didn’t have a module called “Contracts everywhere” … so I just created one (no further values)
the whole table is not displayed if I use the “read only” option, without that option the table is displayed, empty … and looks nearly like my version from before (I could choose contracts)
the script docType is Client Script, coz the result was not as expected I created a second one (also enabled) one is Apply to “List”, the other one is Apply to “Form”… not sure which one is the right one.
after Customizing I click on action->reload
Maybe some helpful things which I should now?:
do I have to empty a cache somewhere else?
how can I check if the script runs proper?
And about your note
You should consider create an app and store on it all the customization
that sounds good/interesting … maybe you can recommend a link to a beginner tutorial/ documentation too?
And a big thank you for the script, alone from reading I got a much better understanding about how to use client scripts
Don’t worry about that, the module “name” is just a joke
“Read only” should work as … “read only”, visibility depends on “Hidden” or visibility condition … Use bench clear-cache to assure fresh data. I recommend “Read only” to avoid users modify data from the “fake” table.
Client Script → apply to Form. This kind of scripts runs when you are working into the form, this is our case. “List” scripts work for listviews.
To some debugging, open the console located in the browser developer tools (press F12 in most browsers). After this, open Employee Doctype, and we will see if frappe throws errors. Some comment code in the script (remove comments) contents info that should appears in the console.
It could be helpful too if you share some screenshots of your doctypes, script, etc …
In this videos and docs you will see how to create apps, and link frappe objects to this apps.
You are really welcome. I’m happy to help others, same way other people helps to me. Play with the framework and enjoy learning. Be patient, there are a lot of things to understand!
this was my guess too … but it’s still the thing which is happened:
“Read only” is marked: The whole table will not appear (just nothing, also not the borders or title and so on … just nothing)
“Read only” is not marked: The table appears (still empty)
I guess that I can just not execute your script on the correct way … now I have to understand how the console works … I already activated your console outputs in the script, but I cannot find anything about the script in the console…
and about the console … until now I hvae no clue what to do/how to find anything … I tried the search option and put some words/strings in which are related to the script … but nothing to see … so I just add a screenshot from the console screen … but I’m pretty sure that’s not what you need to see …