Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

How to Upload a file using Webapp Adobe Campaign?

Avatar

Level 2

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 Raghavmarcel.gent.86​ Can you guys help me on this.

Thanks

Srikanth

13 Replies

Avatar

Community Advisor

Hello srikanthr81596981​,

why not use functionality which is already there?

  1. Web app form with file upload
  2. Save file to public resources
  3. Link public resource to your custom table

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?

Avatar

Community Advisor

Hello srikanthr64692681,

In web app edit tab choose Page activity

1478933_pastedImage_0.png

In page Advanced controls -> File

1478941_pastedImage_16.png

1478935_pastedImage_11.png

Or you can change any input to file type input in "Selection controls"

1478940_pastedImage_15.png

1478939_pastedImage_13.png

Set up storage by choosing your context variable (you can create them here aswell)

1478945_pastedImage_17.png

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.

Avatar

Community Advisor

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

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?

Avatar

Community Advisor

I think not as fileResObj already has this in it. But you need to try that

At this time it is just creating an entry not upload the actual file on to server.

Avatar

Community Advisor

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

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

1479010_pastedImage_0.png

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