Cascading pulling of Data

Hi,

Is it possible to have a cascading effect of pulling of data. For example:

If we pull the customer in the sales order then the shipping address is populated automatically in the link field and the address but now if I wanted to pull another data field from the address field then I have to reload the address field for the add_fetch to work.

Is it possible to fetch that field also when the link field of the shipping address is pulled since for add_fetch we have reload the shipping address.

Can you explain the use case? (which additional field you need to pull)

You might have to write a custom trigger for this.

1 Like

The use case is like this:
In Sales Invoice: If we select a customer, then default shipping address is pulled. Now we have a custom field like shipping_address_title, which is pulled when we make changes to the shipping address field.

Now I would want that when a customer is pulled which results in pulling of the shipping_address_name (link field) which would mean that the address_title would also get fetched when the customer is selected but that field is depended upon the shipping _address_name field.

I hope you understand that.

I have the following custom script in my sales invoice running, now what I want is that as soon as the customer is changed the fields being fetched from the customer are Taxes and Shipping Address as per the default code. Now I want that fields which are to be fetched from Taxes and Shipping address should also be fetched when we change the customer but that is not happeing with the below code, instead we have to manually reload the shipping address to load ship_to field and for letter_head and c_form applicable we have to reload the taxes field. Is there a way we could avoid the 2 reloads for no reason.

cur_frm.cscript.custom_customer = function() {
	cur_frm.script_manager.trigger("taxes_and_charges");
	cur_frm.script_manager.trigger('shipping_address_name');
}

cur_frm.add_fetch('item_code','cetsh_number','cetsh_number');
cur_frm.add_fetch('customer','excise_number','excise_number');
cur_frm.add_fetch('customer','tin_no','tin_no');
cur_frm.add_fetch('customer','payment_terms','payment_terms');
cur_frm.add_fetch('taxes_and_charges','letter_head','letter_head');
cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');
cur_frm.add_fetch('shipping_address_name','address_title','ship_to');

will only re-trigger tax calculations and not pull these values again. You need to call the link validation.

Try this:

cur_frm.get_field("customer").validate(cur_frm.doc.customer);

Tried the script but no luck.

I am sharing my code now maybe there is some typo

cur_frm.cscript.custom_customer = function() {
cur_frm.script_manager.trigger("taxes_and_charges");
cur_frm.script_manager.trigger('shipping_address_name');
}

cur_frm.get_field("customer").validate(cur_frm.doc.customer);
cur_frm.get_field("shipping_address_name").validate(cur_frm.doc.address);
cur_frm.get_field("taxes_and_charges").validate(cur_frm.doc.sales_taxes_and_charges_master);

cur_frm.add_fetch('item_code','cetsh_number','cetsh_number');
cur_frm.add_fetch('customer','excise_number','excise_number');
cur_frm.add_fetch('customer','tin_no','tin_no');
cur_frm.add_fetch('customer','payment_terms','payment_terms');
cur_frm.add_fetch('taxes_and_charges','letter_head','letter_head');
cur_frm.add_fetch('taxes_and_charges','c_form_applicable','c_form_applicable');
cur_frm.add_fetch('shipping_address_name','address_title','ship_to');

Is it possible to pull fields from a reference field or not.

Field A (is changed) —> Field B is pulled from Field A ====> FIeld C which is supposed to be pulled from Field B would also be fetched without changing Field B.

bump
This is to bump up the post.
bump

Not a good design - because if there are server calls in Field B, Field C should not be triggered until Field B’s server calls are finished.

Then what does this mean, I thought that the above script would help in pulling data from the customer master and if I replace the field name then the system would also fetch the data from the address field.

To fetch the data from the address field the only possible way as per current structure is to manually edit the address link and re-select the field or is there a work around.

This will re-trigger the fetches of customer - so you can call this via another trigger (provided it does not have a server call)