How to add rows to Items table in Opportunity by script

I'm using ERPNext 3.6.1. If I wanted to add a new row to the Items table in Opportunity with certain Item Code already determined, via a script, how would I do this?

I'm currently using a very hackish solution to get a new row started by using $('.grid-add-row').trigger('click'); in opportunity.js, but even then I do not know how to set the Item Code field automatically to the desired value.

Thanks!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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/20b5dcb8-aef0-4258-85c9-3f8309b6b04e%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Actually, I just found I could follow that up with $('input[data-fieldname="item_code"]').val('Item code here'); to get the desired effect. Still, if there's a cleaner way of doing this, feel free to let me know. :)

On Tuesday, August 19, 2014 2:02:35 PM UTC-4, Chris Horton wrote:
I'm using ERPNext 3.6.1. If I wanted to add a new row to the Items table in Opportunity with certain Item Code already determined, via a script, how would I do this?

I'm currently using a very hackish solution to get a new row started by using $('.grid-add-row').trigger('click'); in opportunity.js, but even then I do not know how to set the Item Code field automatically to the desired value.

Thanks!



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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/ee495dbd-bb01-47f7-af3e-e21ec1ff5249%40googlegroups.com.

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