Dynamic Link doesn't work in javascript frappe.ui.Dialog

Hi All,

I have the following block of code in a javascript file:

var fields = [
	{fieldtype:'Check', fieldname:'is_group', label:__('Is Group?'),
		description: __("Further nodes can be only created under 'Group' type nodes")},
	{fieldtype:'Data', fieldname: 'group_name', 
		label:__('Group Name')}, 
	{fieldtype:'Link', fieldname: 'document_type', 
		label:__('Type of Group'), options:'DocType'}, 
	{fieldtype:'Dynamic Link', fieldname: 'document_id',
	label:__('Document Id'), options:'document_type'}
]

var d = new frappe.ui.Dialog({
	title: __('New {0}',[__(me.ctype)]),
	fields: fields
})

The dialog box pops up ok. However, when I select the required DocType in the field document_type, there are no documents produced in the field document_id.

I’d appreciate any guidance.

Regards,

@Chude_Osiegbu, try add this, at end of you script

d.fields_dict.document_type.$input.on('change', function(){
  d.fields_dict.document_id.refresh();
}); 
2 Likes

Many thanks @max_morais_dmm

Hi @max_morais_dmm,

The following statement doesn’t seem to work. It runs but no data shows up in the field document_id.

d.fields_dict.document_id.refresh();

@Chude_Osiegbu, maybe do you need open a issue!

@max_morais_dmm, will do! Thanks.

@max_morais_dmm, issue raised: Bug: Dynamic Link doesn’t work in javascript frappe.ui.Dialog · Issue #1561 · frappe/frappe · GitHub