This topic contains 6 replies, has 0 voices, and was last updated by qpongrass 6 years, 6 months ago.
-
AuthorPosts
-
qpongrass- Contributions: 0
- Level 1
- ☆
Is it possible to use a standard html input type=file on an external suitelet and retrieve the file on the post action either via request.getFile or some other method? The NetSuite form.addField makes it impossible to customize the position, color, size, etc. of the file field.
This is a cached copy. Click here to see the original post. -
JohnCCole- Contributions: 0
- Level 1
- ☆
I've done something like what your asking. I have a node.js application uploading a file to a suitelet. As long as the enctype on the form is multipart/form-data, and the name and id of the form file field is 'file', I can access that file in the suitelet using getFile.
-
qpongrass- Contributions: 0
- Level 1
- ☆
JohnCCole, how did you get it to work? Could you provide some code samples? I tried using the following code, but the file object is always null on the form post.
On Get:
html += '<form action="/app/site/hosting/scriptlet.nl?script=377&deploy=1" method="post" enctype="multipart/form-data">'
html += 'First name: <input type="text" name="fname"><br>'
html += '<input type="file" name="nsfile" id="nsfile"><br>'
html += '<input type="submit" value="Submit">'
html += '</form>'
form.addField('html', 'inlinehtml', null,null,null).setDefaultValue(html);
response.writePage(form);
On post:
var file = request.getFile("nsfile")
-
JohnCCole- Contributions: 0
- Level 1
- ☆
Not sure if it's a un-intended feature but it appears if you write the response with write method instead of writePage it will work.
If you use an NSForm object and then call writePage it appears an actual file field has to be added to the form (not raw html) for things to work, but then you're back to not being able to perhaps position the NetSuite field the way you want.
I'm assuming you don't want to be without the NS API that comes with a form when doing a writePage so what kind of styling/positioning are you trying to do with the file field?
-
qpongrass- Contributions: 0
- Level 1
- ☆
Genius. Thank you. This alleviates one of my biggest headaches.
Here is the code on the GET:
html += '<form action="/app/site/hosting/scriptlet.nl?script=377&deploy=1" method="post" enctype="multipart/form-data">'
html += 'First name: <input type="text" name="fname"><br>'
html += '<input type="file" name="nsfile" id="nsfile"><br>'
html += '<input type="submit" value="Submit">'
html += '</form>'
response.write(html);
POST can use the NS API as normal:
var file = request.getFile("nsfile")
file.setFolder(981194)
var id = nlapiSubmitFile(file)
-
JohnCCole- Contributions: 0
- Level 1
- ☆
Not a problem. As long as you don't need the SuiteScript API on the client side it does the trick.
-
qpongrass- Contributions: 0
- Level 1
- ☆
Correct. This really solved a long-standing deficiency in my understanding.
-
AuthorPosts
You must be logged in to reply to this topic.