Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctype Links not updating #26041

Closed
ajiragroup opened this issue Apr 14, 2024 · 5 comments
Closed

Doctype Links not updating #26041

ajiragroup opened this issue Apr 14, 2024 · 5 comments
Labels

Comments

@ajiragroup
Copy link
Contributor

ajiragroup commented Apr 14, 2024

Information about bug

I had added a doctype link to project doctype. Now I want to delete that link. When doing so, this happens:

1.mp4

Module

projects

Version

erpnext 15.16.2
frappe 15.17.1

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

No response

@ajiragroup ajiragroup added the bug label Apr 14, 2024
@Nihantra-Patel Nihantra-Patel transferred this issue from frappe/erpnext Apr 18, 2024
@karanwilson
Copy link
Contributor

Hi @ajiragroup, this issue is also happening in Version-14;
Seems like Frappe team is also working in this issue; following are some error logs from the console:-

grid_row.js:126 TypeError: Cannot read properties of undefined (reading 'name')
at GridRow.refresh_field (grid_row.js:1438:29)
at grid_row.js:710:10
at Array.forEach ()
at GridRow.setup_columns (grid_row.js:688:29)
at GridRow.render_row (grid_row.js:309:8)
at GridRow.refresh (grid_row.js:206:9)
at Grid.render_result_rows (grid.js:479:14)
at Grid.refresh (grid.js:432:8)
at grid_row.js:121:18
(anonymous) @ grid_row.js:126
Promise.catch (async)
remove @ grid_row.js:124
(anonymous) @ grid.js:239
Promise.then (async)
(anonymous) @ dom.js:262
frappe.run_serially @ dom.js:260
delete_rows @ grid.js:260
(anonymous) @ utils.js:1071
dispatch @ jquery.js:5135
elemData.handle @ jquery.js:4939

============================================

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'name')
at GridRow.refresh_field (grid_row.js:1438:29)
at grid_row.js:710:10
at Array.forEach ()
at GridRow.setup_columns (grid_row.js:688:29)
at GridRow.render_row (grid_row.js:309:8)
at GridRow.refresh (grid_row.js:206:9)
at Grid.render_result_rows (grid.js:479:14)
at Grid.refresh (grid.js:432:8)
at grid.js:254:10

============================================

Uncaught TypeError: Cannot read properties of undefined (reading '__checked')
at grid.js:326:20
at Array.map ()
at Grid.get_selected_children (grid.js:325:5)
at Grid.delete_rows (grid.js:232:32)
at HTMLButtonElement. (utils.js:1071:20)
at HTMLDivElement.dispatch (jquery.js:5135:27)
at elemData.handle (jquery.js:4939:28)

@karanwilson
Copy link
Contributor

karanwilson commented May 2, 2024

Hi @ajiragroup ,

To resolve this bug, please access the following file of the Frappe App (in your instance):-
frappe-bench/apps/frappe/frappe/custom/doctype/customize_form/customize_form.js

Please update this file with the added lines of code as per the attached file:-
customize_form.js.txt
(I added the txt extension to the file in order to attach it here)

The following lines in bold were added to the attached "customize_form.js" file:-

frappe.ui.form.on("DocType Link", {
before_links_remove: function (frm, doctype, name) {
...
parenttype = row.parenttype; // used in the event links_remove
parent = row.parent; // used in the event links_remove

...
},
...
links_remove: function (frm, doctype, name) {
// replicate the changed rows from the browser's copy of the parent doc to the current 'Customize Form' doc
let parent_doc = locals[parenttype][parent];
frm.doc.links = parent_doc.links;
},

});

frappe.ui.form.on("DocType Action", {
before_actions_remove: function (frm, doctype, name) {
...
parenttype = row.parenttype; // used in the event actions_remove
parent = row.parent; // used in the event actions_remove

...
},
...
actions_remove: function (frm, doctype, name) {
// replicate the changed rows from the browser's copy of the parent doc to the current 'Customize Form' doc
let parent_doc = locals[parenttype][parent];
frm.doc.actions = parent_doc.actions;
},

});

frappe.ui.form.on("DocType State", {
before_states_remove: function (frm, doctype, name) {
...
parenttype = row.parenttype; // used in the event states_remove
parent = row.parent; // used in the event states_remove

...
},
...
states_remove: function (frm, doctype, name) {
// replicate the changed rows from the browser's copy of the parent doc to the current 'Customize Form' doc
let parent_doc = locals[parenttype][parent];
frm.doc.states = parent_doc.states;
},

});

@nabinhait @Nihantra-Patel please let me know whether I should submit a PR for this.

@karanwilson
Copy link
Contributor

Edited the frm.refresh_fields() statements above to add the specific fieldnames.
Also made the edit in the attached file "customize_form.js.txt"

karanwilson added a commit to karanwilson/frappe that referenced this issue May 3, 2024
karanwilson added a commit to karanwilson/frappe that referenced this issue May 3, 2024
@karanwilson
Copy link
Contributor

Upon final testing, I realised that the frm.refresh_field() or frm.refresh_fields() are indeed redundant;
there are standard refresh triggers that happen upon any row changes;
Hence removed these refresh_field statements from the above comment and from the attached file.

karanwilson added a commit to karanwilson/frappe that referenced this issue May 6, 2024
    Doctype Links not updating frappe#26041
    frappe#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;
karanwilson added a commit to karanwilson/frappe that referenced this issue May 10, 2024
karanwilson added a commit to karanwilson/frappe that referenced this issue May 11, 2024
frappe#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;
karanwilson added a commit to karanwilson/frappe that referenced this issue May 11, 2024
In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states
karanwilson added a commit to karanwilson/frappe that referenced this issue May 11, 2024
akhilnarang pushed a commit that referenced this issue Jun 3, 2024
…s on child-tables (#26344)

* fix: Doctype Links not updating #26041
#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;

* fix: Doctype Links not updating #26041

In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states

* Revert "In customize_form.js :-"

This reverts commit 6732f0a.

* fix: Doctype Links not updating #26041

* style: amended spacing as per 'prettier' in precommit

* style: added comma after last event definitions in child doctype, as per 'prettier' in precommit
mergify bot pushed a commit that referenced this issue Jun 3, 2024
…s on child-tables (#26344)

* fix: Doctype Links not updating #26041
#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;

* fix: Doctype Links not updating #26041

In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states

* Revert "In customize_form.js :-"

This reverts commit 6732f0a.

* fix: Doctype Links not updating #26041

* style: amended spacing as per 'prettier' in precommit

* style: added comma after last event definitions in child doctype, as per 'prettier' in precommit

(cherry picked from commit b9f4845)
mergify bot pushed a commit that referenced this issue Jun 3, 2024
…s on child-tables (#26344)

* fix: Doctype Links not updating #26041
#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;

* fix: Doctype Links not updating #26041

In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states

* Revert "In customize_form.js :-"

This reverts commit 6732f0a.

* fix: Doctype Links not updating #26041

* style: amended spacing as per 'prettier' in precommit

* style: added comma after last event definitions in child doctype, as per 'prettier' in precommit

(cherry picked from commit b9f4845)
akhilnarang pushed a commit that referenced this issue Jun 3, 2024
…s on child-tables (#26344) (#26644)

* fix: Doctype Links not updating #26041
#26041

In refresh_field(fieldname, txt) function of grid_row.js, added the comments :-
    // the below if statement is added to factor in the exception when this.doc is undefined -
    // - after row removals via customize_form.js on links, actions and states child-tables
    if (this.doc)
            field.docname = this.doc.name;

* fix: Doctype Links not updating #26041

In customize_form.js :-
defined parent and parenttype as local variables in the event functions for child tables links, actions and states

* Revert "In customize_form.js :-"

This reverts commit 6732f0a.

* fix: Doctype Links not updating #26041

* style: amended spacing as per 'prettier' in precommit

* style: added comma after last event definitions in child doctype, as per 'prettier' in precommit

(cherry picked from commit b9f4845)

Co-authored-by: Karan Wilson <48678570+karanwilson@users.noreply.github.com>
frappe-pr-bot pushed a commit that referenced this issue Jun 4, 2024
## [15.29.1](v15.29.0...v15.29.1) (2024-06-04)

### Bug Fixes

* **address_query:** show search fields in description if set ([4db0b53](4db0b53))
* **address_query:** use title field if set ([01a00e3](01a00e3))
* allow creation of workspace based on desk role perms ([fb898f7](fb898f7))
* Auto Email Report not working when Add Total Row is enabled ([#26668](#26668)) ([e585657](e585657))
* Avoid concurrent TODO updates ([#26594](#26594)) ([cee96b9](cee96b9))
* bypass IP restriction for the methods required for our socketio backend ([42011c9](42011c9))
* **checkbox:** Fix checkbox size on small screens ([#26596](#26596)) ([#26612](#26612)) ([fc2a852](fc2a852))
* delete old user notification settings when merging users ([#26604](#26604)) ([#26619](#26619)) ([af1a47d](af1a47d))
* don't copy "Standard" on dashboard chart (backport [#26649](#26649)) ([#26651](#26651)) ([719522d](719522d))
* front-end bug in 'customize_form.js', triggered by delete actions on child-tables ([#26344](#26344)) ([b9f4845](b9f4845)), closes [#26041](#26041) [#26041](https://github.com/frappe/issues/26041) [#26041](#26041)
* kanban filters fixes ([#26605](#26605)) ([#26610](#26610)) ([af7f550](af7f550))
* **link-preview:** Correct synchronization of preview data on change. ([#26641](#26641)) ([#26654](#26654)) ([c34c1d1](c34c1d1))
* **make_request:** don't blindly try to check the content-type ([2fc914f](2fc914f))
* **number_card:** ensure value is returned ([0a91f04](0a91f04))
* **UX:** multi-tab experience ([#26309](#26309)) ([#26646](#26646)) ([3e4fff7](3e4fff7))

### Performance Improvements

* memory leak on kanban refresh ([#26597](#26597)) ([#26599](#26599)) ([8b8a297](8b8a297))
* rearrange some frequent jobs ([#26591](#26591)) ([#26603](#26603)) ([d9b7d73](d9b7d73))
@karanwilson
Copy link
Contributor

karanwilson commented Jun 11, 2024

This issue has been resolved in Frappe version 15.29.1 and higher.

#26344 (comment)

@ajiragroup @nabinhait

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants