Expand my Community achievements bar.

how can we create a form input element to upload CSV file and fetch that data in schema

Avatar

Level 1

I have to create a form in which I want to upload a CSV file and fetch that CSV file data in respective schema.

8 Replies

Avatar

Community Advisor

Hi @rajansingh ,

In general, input form is used to insert or update a single record at a time in a particular linked schema.

Instead, you can create a Workflow, create a data loading file followed by update data activity and configure all the attributes. Its a one time job to create this workflow. And later once it is build, whenever you want to insert record using CSV file, you can go to this data loading activity, upload this csv file and run the workflow. So your data in csv file will get inserted in respective schema.

 

Example, if you have a recipient data csv file, then you can create a workflow like below, and upload your csv file in the data loading.

ParthaSarathy_0-1686744906055.png

 

Data loading:

Data loading configuration

ParthaSarathy_1-1686744967823.png

Or you can upload your csv file in any SFTP, and collect it via file transfer activity and select 'specified in the transition'.

Update data:

Update data configuration

ParthaSarathy_2-1686744989018.png

 

The above workflow structure is just an example. You can modify it with your use case like by adding deduplication etc.

Avatar

Level 6

Hi @rajansingh ,

You need to create a webapp for same.

 

n web app edit tab choose Page activity

aggabhi_0-1686746399609.png

 

In page Advanced controls -> File

aggabhi_1-1686746399596.png

 

aggabhi_2-1686746399356.png

 

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

aggabhi_3-1686746399620.png

 

aggabhi_4-1686746401091.png

 

 

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

aggabhi_5-1686746400878.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(); 

 

 

Avatar

Community Advisor

Hi @rajansingh@aggabhi@ParthaSarathy@jjwatson79,

Uploading using a web app is fine. But how can that file be processed by a workflow for data import in the case where the webapp is published to the tracking server, and the upload happens on the tracking server?

Any idea about it?


Regards,

Ishan

Avatar

Community Advisor

Might be  If you know the server path where the file is stored after uploading in webApp, you can create a import Workflow in Adobe campaign, fetch the file using file transfer/ file collector > data loading > Update data and update the records in destination schema. Schedule this workflow to run either every1 hour or every 30 mins.

 

Or Instead of this process, We can create the same workflow (remove file transfer/ file collector), and whenever you needs to upload a csv file and insert the records in schema, directly go to this import workflow, upload the file in data loading and start the workflow.

 

Or if the person who wants to upload the file don't have access to Adobe campaign, they can drop the file in some SFTP, and We can collect the file using file transfer activity in the same Import workflow created and import those records into the schema.

 

Avatar

Level 2

Without knowing the use-case in detail, this is a hard question to answer. There scenarios where it could be done through the storage activity of the web-app rather than through a workflow, for example. You could also use JS to inject the data from the file into the marketing instance DB.

 

Without knowing more detail about the use case, I don't feel like I can answer the question with any kind of confidence that what I am proposing is sensible. I do feel that it is more likely that the solution would NOT be a web-app based one. The use cases where that would be the best solution seem very few to me.

 

So, as I indicated in my reply, I will await the use case before I offer any more detail. Until then, I worry that I may be answering the wrong question.

 

 

Avatar

Level 2

Hi @rajansingh,

 

Please give the use case that you are trying to solve? It may be possible to use a web-app, as @aggabhi has suggested. It is an unusual way to load data. Perhaps with a clearer understanding of your use case, and WHY you need the form option, we can recommend a better approach than the one you have in mind. 

Avatar

Administrator

Hi @rajansingh,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa