How to Upload a file using Webapp Adobe Campaign? | Community
Skip to main content
Level 2
May 2, 2018

How to Upload a file using Webapp Adobe Campaign?

  • May 2, 2018
  • 1 reply
  • 15327 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Marcel_Szimonisz
Community Advisor
Community Advisor
May 3, 2018

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

Level 2
May 3, 2018

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?

Level 2
May 3, 2018

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.