Custom fields in print format

Hi,

I need to display on my format printing, custom fields of an item quotation. In my template, I have the following code: 

var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details');
// It works! 

for (var i=0;i<quotationItems.length;i++) {

            var item = quotationItems[i];
            var itemDetail = getchildren('Item', item.item_code, 'item_code');
            // Always returns an empty array for itemDetail :( 
            ...
}


 So I tried using the function below, which worked, but it is an asynchronous call and so does not work for print format.

           wn.call({
                method:"webnotes.client.get_value",
                args: {
                    doctype:"Item",
                    filters: {
                        item_code: item.item_code
                    },
                    fieldname:["default_warehouse", "customA", "customB"]
                }, 
                callback: function(r) { 
                    console.log(r.message.default_warehouse);
               }
            });

How do I get item details synchronously? What is the other solution?

thanks. (Excuse me for my bad English)




Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1e4e41e7-1b18-4d83-bb7f-3d62ae45e5a0%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

In the first example, variable item contains the instance of each item row. So you can directly access value of item_code by using item.item_code

On 5 May 2014 04:06, "Edney Oliveira" <ed...@gmail.com> wrote:
Hi,

I need to display on my format printing, custom fields of an item quotation. In my template, I have the following code:

var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details');
// It works!

for (var i=0;i<quotationItems.length;i++) {

var item = quotationItems[i];
var itemDetail = getchildren('Item', item.item_code, 'item_code');
// Always returns an empty array for itemDetail :(
...
}


So I tried using the function below, which worked, but it is an asynchronous call and so does not work for print format.

wn.call({
method:"webnotes.client.get_value",
args: {
doctype:"Item",
filters: {
item_code: item.item_code
},
fieldname:["default_warehouse", "customA", "customB"]
},
callback: function(r) {
console.log(r.message.default_warehouse);
}
});

How do I get item details synchronously? What is the other solution?

thanks. (Excuse me for my bad English)




Note:



If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.



    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1e4e41e7-1b18-4d83-bb7f-3d62ae45e5a0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/CA%2BCj7tg%3D3if%3DRjmTddKunSek8kQj4ANDD9Kn%2BP_ReS%2B88bg1jw%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.
Hi Nabin Hait,

    When I call "var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details'); .... var item = quotationItems[i];" the item has only a few fields. I need the other fields of the item. So I need to call another function to retrieve the other fields of the Item.

I attached a file that shows the object data item. See the field that need is not there: data_warehouse among others.

Custom scripts modify the result of calling the method getchildren? 

Thanks,
Edney

Em segunda-feira, 5 de maio de 2014 00h58min54s UTC-3, Nabin Hait escreveu:

In the first example,  variable item contains the instance of each item row. So you can directly access value of item_code by using item.item_code

On 5 May 2014 04:06, "Edney Oliveira" <ed...@gmail.com> wrote:
Hi,

I need to display on my format printing, custom fields of an item quotation. In my template, I have the following code: 

var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details');
// It works! 

for (var i=0;i<quotationItems.length;i++) {

            var item = quotationItems[i];
            var itemDetail = getchildren('Item', item.item_code, 'item_code');
            // Always returns an empty array for itemDetail :( 
            ...
}


 So I tried using the function below, which worked, but it is an asynchronous call and so does not work for print format.

           wn.call({
                method:"webnotes.client.get_value",
                args: {
                    doctype:"Item",
                    filters: {
                        item_code: item.item_code
                    },
                    fieldname:["default_warehouse", "customA", "customB"]
                }, 
                callback: function(r) { 
                    console.log(r.message.default_warehouse);
               }
            });

How do I get item details synchronously? What is the other solution?

thanks. (Excuse me for my bad English)




Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1e4e41e7-1b18-4d83-bb7f-3d62ae45e5a0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/33f2a0ea-208b-409b-a8d8-786dd655ca2b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
If you did not modify getchildren function, it should give all the fields value of each row including custom fields. Make sure you have created custom field "data_warehouse" for Quotation Item doctype.


On 05-May-2014, at 7:31 pm, Edney Oliveira <ed...@gmail.com> wrote:

Hi Nabin Hait,

    When I call "var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details'); .... var item = quotationItems[i];" the item has only a few fields. I need the other fields of the item. So I need to call another function to retrieve the other fields of the Item.

I attached a file that shows the object data item. See the field that need is not there: data_warehouse among others.

Custom scripts modify the result of calling the method getchildren? 

Thanks,
Edney

Em segunda-feira, 5 de maio de 2014 00h58min54s UTC-3, Nabin Hait escreveu:

In the first example,  variable item contains the instance of each item row. So you can directly access value of item_code by using item.item_code

On 5 May 2014 04:06, "Edney Oliveira" <ed...@gmail.com> wrote:
Hi,

I need to display on my format printing, custom fields of an item quotation. In my template, I have the following code: 

var quotationItems = getchildren('Quotation Item', doc.name, 'quotation_details');
// It works! 

for (var i=0;i<quotationItems.length;i++) {

            var item = quotationItems[i];
            var itemDetail = getchildren('Item', item.item_code, 'item_code');
            // Always returns an empty array for itemDetail :( 
            ...
}


 So I tried using the function below, which worked, but it is an asynchronous call and so does not work for print format.

           wn.call({
                method:"webnotes.client.get_value",
                args: {
                    doctype:"Item",
                    filters: {
                        item_code: item.item_code
                    },
                    fieldname:["default_warehouse", "customA", "customB"]
                }, 
                callback: function(r) { 
                    console.log(r.message.default_warehouse);
               }
            });

How do I get item details synchronously? What is the other solution?

thanks. (Excuse me for my bad English)





Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1e4e41e7-1b18-4d83-bb7f-3d62ae45e5a0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.




Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/33f2a0ea-208b-409b-a8d8-786dd655ca2b%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

    <Screen Shot 2014-05-05 at 10.56.54 AM.png>



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/2AEDD987-BC19-4DFC-B181-1BE683FA3A07%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.