Hello,
I am trying to Create WebApp for Support team, where we handle new requests. I am trying to add Upload File by linking fileRes to Custom table I created, Unfortunately it is showing error when click the Storage option.Vipul Raghav marcel.gent.86 Can you guys help me on this.
Thanks
Srikanth
Hello srikanthr81596981,
why not use functionality which is already there?
1.
choose context variable (eg ctx.vars.file) to save your file from form
2-3 step:
See any file res xml to know what to save
ctx.vars.file -->has e.g @md5, @originalName.
//create all fields you want to save
//create xml
var fileResXml = <fileRes contentType={contentType}
internalName={intName} label={originalName} md5={md5Var}
name={destFileName} originalName={originalName}
xtkschema="xtk:fileRes"><folder id={folderId}/></fileRes>;
//create file res obj
var fileResObj = xtk.fileRes.create(fileResXml);
//publish
fileResobj.PublishIfNeeded();
//save it to db
fileResobj.save();
var fileResId = *query resource id by unique internal name*;
///save resource id to linked table?
fileResobj.save();
fileRfileResobj.save();esobj.save();
Hope this helps,
Marcel
Hi Marcel,
Thanks for the reply . I am
actually new to creating web Apps but I did not find the web app form with file upload template. Can you please let me know where exactly to find it?
Views
Replies
Total Likes
Hello srikanthr64692681,
In web app edit tab choose Page activity
In page Advanced controls -> File
Or you can change any input to file type input in "Selection controls"
Set up storage by choosing your context variable (you can create them here aswell)
After page JS activity has to be placed with following-ish code
The variable you set for the image field will contain following attributes after submit
<ctx>
<vars>
<fileImg id="0" md5="af859bcc5957fd1a60f7387d07c672ff" originalName="C:\Users\USER\Pictures\3RzNQc8Ia07A_GjjY49XOt.jpg"/>
</vars>
</ctx>
so that means in JS you can distinguish from it md5 string, contentType ...
ctx.vars.fileImg -->has attributes e.g @md5, @originalName if you want to see all of them
//create all fields you want to save
//create xml
var fileResXml = <fileRes contentType={contentType}
internalName={intName} label={originalName} md5={md5Var}
name={destFileName} originalName={originalName}
xtkschema="xtk:fileRes"><folder id={folderId}/></fileRes>;
//create file res obj
var fileResObj = xtk.fileRes.create(fileResXml);
//publish
fileResobj.PublishIfNeeded();
//save it to db
fileResobj.save();
var fileResId = *query resource id by unique internal name*;
///save resource id to linked table?
fileResobj.save();
Marcel
Awesome Thanks marcel. I will implement and let you know.
Views
Replies
Total Likes
Hello again,
one more thing
Maybe this will be needed
fileRes.PostUpload ();
As well as setting storageType="5" to that fileRes xml --> 5 is default although i do not know what that means
Let me know
Marcel
Views
Replies
Total Likes
Hi Marcel , I am able to save the file and but it is not uploaded on the server(I need to manually go and upload), Like you have mentioned it is something to do with below method
fileResObj.PostUpload(); Post Upload takes XML params
do I need to define like
fileResObj.PostUpload(<params name={orignialName} md5={md5var} />)
And also How do I to link to my custom Table?
Views
Replies
Total Likes
I think not as fileResObj already has this in it. But you need to try that
Views
Replies
Total Likes
At this time it is just creating an entry not upload the actual file on to server.
Hello,
try to combine this answer with this
I want to Upload images to Public resources every morning. Is it possible to automate this process.
But you might check if publishIfNeeded() saved the same resource on every tracking server.
Marcel
Views
Replies
Total Likes
Hi Marcel,
Thanks for all your help, I am not able to upload it on the Server. There must be something I am missing my Form is creating an entry with definied variable in the script but it is not uploading the file to server. I am excepting something like this
Views
Replies
Total Likes
Hi,
I am facing the same problem too. Any solution to this?
And also when I try to retrieve ctx.vars.file.@md5 or ctx.vars.file.@originalName both return blank value. The record is stored inside the xtk:fileRes schema after I run the script but with blank value for both Original Name and md5 key. And the record appears under public resources but no file uploaded inside.
Regards,
Cho
Views
Replies
Total Likes
for storageType
Hi,
Is there any solution ?
Thanks
Naveen S
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies