Wednesday, 16 March 2016

[ERPNext] get value from another doc in javascript

Here is one example to fetch customer in Delivery Note using frappe.client.get_value method.
 Using this you can fetch values from another doc.


frappe.call({
    'method': 'frappe.client.get_value',
    'args': {
        'doctype': 'Delivery Note',
        'fieldname': 'customer',
          'filters': {
            'name': 'DN-00003'
          }
        }
        ,
       callback: function(r){
                              msgprint(r.message.customer);


       }
   
});

3 comments:

  1. Hello Sambjahaji,
    i am looking for some example for create custom Sales Invoice template. I use some examples but i got error Warning: This Print Format is in old style and cannot be generated via the API. I need to show delivery note documents on sales invoice and sum them. Default shows multiple same docs.

    ReplyDelete
  2. I have send you an email.

    You can use
    Following code will print unique item

    {% for group in doc.items|groupby('item_code') %}
    {{ group.grouper or ''}},

    {% for item in group.list %}
    {{ item.qty }} {{ item.amount }}

    {% endfor %}

    {%- endfor -%}


    ___________
    {% for group in doc.items|groupby('item_code') %}
    {{ group.grouper or ''}},

    {% for item in group.list %}
    {{ item.qty }} {{ item.amount }}


    {% endfor %}

    Following code will print sum of Qty and Amount of same item(may be you can use this to print sum of box qty)



    sum= {{ group.list|sum(attribute='amount') }}

    {{ group.list|sum(attribute='qty') }}
    {%- endfor -%}

    ReplyDelete
  3. Is it possible to make an error handling condition after the frappe call? For instance, if the customer does not exist throw a certain screen message.

    ReplyDelete