How to get file name or id from "File Upload" Control
Hello,
is it possible to get a name or itemid of a file that was uploaded using "File Upload" Control and put the value in an other field on the form?
Regards,
Marina
-
If you take a look at the schema for your File Upload control, you should see a few repeatable fields which have the data for each file. Among them should be a name and a URL.

From here, you'll need to do some fancy rules and/or JavaScript to grab their values if you need them in other parts of the form, but if you can wait until the process, there are plenty of AgilePoint Activities that can handle repeating schema elements easily.
That should be a good starting point, but if you're still struggling, don't hesitate to post again.
-
Hi,
that's the problem. I tried to create simple/fancy rule to copy file url value to any other text field on the form but the rule doesn't work.
I know that I can handle all uploaded file attributes in the process but in this specific case I'd like to get this value before starting a process.Thanks
Marina
-
Ah, this can get annoying at times. I wrote a bit of JavaScript to get what you need, and hopefully the pictures give you enough of an idea on how to modify it. If you only have one attachment maximum, then the code works as-is, but if you need "n" attachments, you'll have to duplicate the function "n" number of times and fire "n" rules, then change what's in red.



[code]
function SetFieldToFileUploadValue(context, targetFields, dataNames) {
debugger;
var contextField = context.id;
eFormHelper.getFieldValue(
{fieldId: contextField},
function(result) {
var fileArray = result.data[contextField];
for (var i = 0, len = dataNames.length; i < len; i++) {
var data = fileArray[0][dataNames[i]];
eFormHelper.setFieldValue({fieldId: targetFields[i], value: data});
}
}
);
}[/code]
-
Is the File Upload, URL, and File Name section a repeatable subform? If so, how many times can it repeat?
If it can only repeat 2-3 times, then duplicating the function above and renaming it to something like
SetFieldToFileUploadValue0
SetFieldToFileUploadValue1
SetFieldToFileUploadValue2
and changing the red number above should do the trick, although it looks a bit ugly. If it's repeating more than that, I'll have to get some time to mess with the :[this] variable to get it working for an arbitrary number of repeats. I've got a lot of meetings today, so I may not be able to help much until tomorrow. -
Alright, I finally got this one working.
For a field outside of a subform, use this notation in the rule:
["TextBox1", "TextBox2"], ["url", "fileName"]For a field within a subform, use this notation in the rule:
["SubForm1/TextBox3", "SubForm1/TextBox4"], ["url", "fileName"]If you have a subform within a subform, although I haven't tried it, you can probably nest them like so: "SubForm1/SubForm2/Textbox5".
請登入寫評論。
Now, I'm trying to apply this JavaScript on fields inside the subform (for multiple rows). Should it work? Looks that there is a problem to get file upload object...Do you ant idea?
評論
9 條評論