Upload File field

212 views
Skip to first unread message

Paul Dowd

unread,
Mar 26, 2014, 5:48:05 AM3/26/14
to erpnext-u...@googlegroups.com, akshay. jindal
Hi,

Is it possible to have some kind of field that a user can use to upload a specific type of file?

I want to then be able to easily access this file using the API. 

There will be multiple files uploaded to an item and we need to be able to retrieve them individually and I don't think that the attach file system will reliably work for me in this.

Thanks

Paul

Maxwell Morais

unread,
Mar 26, 2014, 8:51:02 AM3/26/14
to erpnext-u...@googlegroups.com

Yes, what you need is add a Upload Custom Field and a validate method for the extension of the file, eg:


function hasExtensions(filename, exts){
    return new RegExp("(" + exts.join("|").replace(/\./g, '\\.') + ')$')).test(filename);
}

cur_frm.my_field_custom(doc, cdt, cdn){
    if (!doc.my_field && !hasExtensions(doc.my_field, [".pdf", ".doc", ".docx"]){
        doc.my_field = undefined;
        cur_frm.refresh_fields();
        wn.msgprint(wn._("Wrong File type"));
}
}

Adapted from: http://stackoverflow.com/questions/4234589/validation-of-file-extension-before-uploading-file



--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/d3e1be09-3289-4932-9fbd-cacb9ed5fb3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Best Regards.

Maxwell Morais
Python Developer powered by Webnotes framework <3

Paul Dowd

unread,
Mar 30, 2014, 7:33:51 PM3/30/14
to erpnext-u...@googlegroups.com
thanks Maxwell, but I'm not sure how to "add a Upload Custom Field" since this isn't one of the field-type options.

Should I be adding a new script or is there a way to add a new Custom Field type?

On Thursday, 27 March 2014 01:51:02 UTC+13, Maxwell wrote:

Yes, what you need is add a Upload Custom Field and a validate method for the extension of the file, eg:


function hasExtensions(filename, exts){
    return new RegExp("(" + exts.join("|").replace(/\./g, '\\.') + ')$')).test(filename);
}

cur_frm.my_field_custom(doc, cdt, cdn){
    if (!doc.my_field && !hasExtensions(doc.my_field, [".pdf", ".doc", ".docx"]){
        doc.my_field = undefined;
        cur_frm.refresh_fields();
        wn.msgprint(wn._("Wrong File type"));
}
}

Adapted from: http://stackoverflow.com/questions/4234589/validation-of-file-extension-before-uploading-file

2014-03-26 6:48 GMT-03:00 Paul Dowd <pd...@myzealand.com>:
Hi,

Is it possible to have some kind of field that a user can use to upload a specific type of file?

I want to then be able to easily access this file using the API. 

There will be multiple files uploaded to an item and we need to be able to retrieve them individually and I don't think that the attach file system will reliably work for me in this.

Thanks

Paul

--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.

Maxwell Morais

unread,
Mar 31, 2014, 7:14:11 AM3/31/14
to erpnext-u...@googlegroups.com
The type of the Custom Field are Upload!

Do you know what your version of ERPNext?

If it is a version less than 3.x the type are "Selecet" and in options you fill "Image"


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/a1b5041e-f68b-4530-b901-fd9e1e0d7931%40googlegroups.com.

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

Paul Dowd

unread,
Apr 2, 2014, 6:59:12 PM4/2/14
to erpnext-u...@googlegroups.com
Hi Maxwell,

It is v3.7.1

I've tried changing the custom field to:
Field Type = Select
Options = Image

All it gives me is a drop down select box where I can select "Image"... which is what I expected it would do. 

Am I missing that field option? Upload isn't an option in the Field Type menu. 

Thanks

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



--

Best Regards.

Maxwell Morais
Python Developer powered by Webnotes framework <3

--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.

Maxwell Morais

unread,
Apr 2, 2014, 9:06:39 PM4/2/14
to erpnext-u...@googlegroups.com
you have a fieldtype named Upload?


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/2839694f-66c3-43f2-b40a-6c7719881f98%40googlegroups.com.

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

Paul Dowd

unread,
Apr 2, 2014, 9:12:10 PM4/2/14
to erpnext-u...@googlegroups.com
nope, it also isn't specified here: http://erpnext.org/doctype-fields

Paul Dowd
Managing Director



--
You received this message because you are subscribed to a topic in the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/erpnext-user-forum/PxTzy9_7Lg8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/CABK1YkM8TA9JNPNwuZrej%3DP1TFYXmqhMBD0PgVHix_poXZR_fg%40mail.gmail.com.

Maxwell Morais

unread,
Apr 2, 2014, 9:25:35 PM4/2/14
to erpnext-u...@googlegroups.com

Paul sorry, the correct option for the field are attach_files:
To check this, goto Setup > Personalize Form > Edit

Select the doctype Item and look the field Image




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

Paul Dowd

unread,
Apr 2, 2014, 9:49:18 PM4/2/14
to erpnext-user-forum
are you referring to the "Customize Form" / "Allow Attach" tickbox??

This solution is what I'm trying to get away from!! :) 

I need to upload multiple files to the Batch doc-type because we have to record multiple PDFs of different government inspections and certifications. We then needs to retrieve those inspections through the API automatically, so we need to be able to reliably reference them. 

Any assistance in figuring out this issue would be awesome.

Thanks

Paul

Paul Dowd
Managing Director



Maxwell Morais

unread,
Apr 2, 2014, 10:05:52 PM4/2/14
to erpnext-u...@googlegroups.com
I'm refer​ring how configure a Upload Field in system (see the atachment)







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

Paul Dowd

unread,
Apr 3, 2014, 8:35:42 PM4/3/14
to erpnext-u...@googlegroups.com, akshay. jindal
fantastic, thanks Maxwell.

To clarify what I've done for others, to create a upload file field you do the following:

1. Create new Custom Field and enter your name/label. 
2. Use: Field Type = Select
3. Use: Options = "attach_files:"

wa...@xavierltd.com

unread,
Apr 4, 2014, 9:04:04 AM4/4/14
to erpnext-u...@googlegroups.com
‎Hi team,

Is there any way to add attachments to emails being sent from ERPNext? For example, after submitting a Sales Invoice, there's an email dialog box that comes ‎up right after. The issue however is that some of us need to attach other documents along with an invoice before it is sent to the customer. 

Any solution? 


Kind regards,

Umair Sayyed

unread,
Apr 4, 2014, 9:43:00 AM4/4/14
to ERPNext User's Forum
Hello Wale,

You should first attach files in Invoice to be sent as an attachment. The attached files will be available for selection at the bottom of email dialog box.




--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

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



--
Thanks and Regards,
Umair Sayyed
www.erpnext.com

wa...@xavierltd.com

unread,
Apr 4, 2014, 10:10:18 AM4/4/14
to ERPNext User's Forum
Wow... Great! Thanks Umair 


Kind regards,
Wale
From: Umair Sayyed
Sent: Friday, April 4, 2014 2:43 PM
To: ERPNext User's Forum
Subject: Re: [erpnext-user-forum] Attachments in Email

Reply all
Reply to author
Forward
0 new messages