Custom fields in print format

57 views
Skip to first unread message

Edney Oliveira

unread,
May 4, 2014, 6:36:25 PM5/4/14
to erpnext-dev...@googlegroups.com
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)


Nabin Hait

unread,
May 4, 2014, 11:58:54 PM5/4/14
to erpnext-dev...@googlegroups.com

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

--
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...@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.

Edney Oliveira

unread,
May 5, 2014, 10:01:40 AM5/5/14
to erpnext-dev...@googlegroups.com
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
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.
Screen Shot 2014-05-05 at 10.56.54 AM.png

Nabin Hait

unread,
May 6, 2014, 1:08:36 AM5/6/14
to erpnext-dev...@googlegroups.com
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.


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@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>

Reply all
Reply to author
Forward
0 new messages