# How can I set a not mandatory file upload widget?

**URL:** <https://community.ofelia.com/t/how-can-i-set-a-not-mandatory-file-upload-widget/7802>\
**Category:** Q&A\
**Created:** [19 September 2016 22:18 UTC](https://community.ofelia.com/t/how-can-i-set-a-not-mandatory-file-upload-widget/7802 "2016-09-19T22:18:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![geovanny.campoverde](https://avatars.discourse-cdn.com/v4/letter/g/ecb155/32.png) [@geovanny.campoverde](https://community.ofelia.com/u/geovanny.campoverde)\
**Post date:** [19 September 2016 22:18 UTC](https://community.ofelia.com/t/how-can-i-set-a-not-mandatory-file-upload-widget/7802/1 "2016-09-19T22:18:37Z")

</div>

Hello,

I have set FALSE IN the property required in a file upload widget but when I run the process and let the widget empty I get the next error:

INFORMACIÓN: org.restlet.Component.BonitaRestletApplication Error while validating expected inputs  
Explanations:  
{} cannot be assigned to FILE

I have found that I need to put **null** in the definition of the json variable. When I press the submit button apparently the form is submitted but the process do not continue to the next actor and I cannot do anything else because the process seems to be in a kind of limbo.

Please, can you help me with that.?

Thanks in advance.

Regards

Geovanny C.

---

<div class="post-metadata">

**Author:** ![Sean\_McP](https://dub1.discourse-cdn.com/flex013/user_avatar/community.ofelia.com/sean_mcp/32/932_2.png) [@Sean\_McP](https://community.ofelia.com/u/Sean_McP)\
**Post date:** [19 September 2016 23:37 UTC](https://community.ofelia.com/t/how-can-i-set-a-not-mandatory-file-upload-widget/7802/2 "2016-09-19T23:37:17Z")

</div>

In your return function you need to specify an if statement something as follows:

`
return { fileUploaded(filename); }
`

`function fileUploaded(filename){
if (filename!==null){ return filename }
else{return null}
}
`

regards  
Seán

_PS: As this reply answers your question, please mark as resolved by ticking the tick mark on the left of this reply._

---

<div class="post-metadata">

**Author:** ![geovanny.campoverde](https://avatars.discourse-cdn.com/v4/letter/g/ecb155/32.png) [@geovanny.campoverde](https://community.ofelia.com/u/geovanny.campoverde)\
**Post date:** [20 September 2016 16:17 UTC](https://community.ofelia.com/t/how-can-i-set-a-not-mandatory-file-upload-widget/7802/3 "2016-09-20T16:17:52Z")

</div>

Thanks for your response Sean.

I got the idea but I don´t know how to implement it in my task.

The forminput variable of my task have the next information (JSON):  
` { "registrarCeseFuncionesInput" : { "informeValidado" : false, "regresarA" : "Seleccione una opción" }, "informeRecursosHumanosDocumentInput" : { } }`  
where informeRecursosHumanosDocumentInput is the variable of the document.  
The formouput variable of my task have the next information (JavaScript Expression)

` return { 'registrarCeseFuncionesInput': $data.formInput.registrarCeseFuncionesInput, 'informeRecursosHumanosDocumentInput': $data.formInput.informeRecursosHumanosDocumentInput };`

and this is my form:

![imgform](http://s16.postimg.org/xmjoox8gl/form.png)

How could I implement your code in my variables?

Thanks in advance.

Regards.

Geovanny C.
