Hi All
Can anyone please help me to understand, how to read multiple files from the SFTP location. the below command picks one file per run.
package -instance: [instance_name] -export:sftp/adobe/export/test.xml -spec:cus:PKGXXX -verbose
Note: The above script is used in nlserver module.
Thank you!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @ukender ,
If the purpose is to export packages, then I think you may be able to use the JS code. I had defined my packages in package definition. So the following code would export packages in package definition one by one. We can filter out any packages based on the namespace or package name.
var query = xtk.queryDef.create( <queryDef schema="xtk:specFile" operation="select"> <select> <node expr="@name"/> <node expr="@namespace"/> <node expr="data"/> </select> </queryDef> ); var res = query.ExecuteQuery(); var exported = 0; for (var i = 0;i<Object.keys(res).length; i++){ logInfo("Exporting Package " + res[i].@name + " to xml"); if(res[i].@namespace == "cus") { try{ var specFile = xtk.specFile.create(res[i]); var package = specFile.GenerateDoc(); var fileName = "<SFTP path>/PKG_" + res[i].@name.toLowerCase() + ".xml"; saveXmlFile(package, fileName); exported++; }catch(err){ logWarning("Package " + res[i].@name + "has not been exported due to an error."); } } else { continue; } }
Hi @ukender
Try with below script:
package -instance: [instance_name] -export:sftp/adobe/export/*.xml -spec:cus:PKGXXX -verbose
Thanks,
Jyoti
Views
Replies
Total Likes
Hi Jyoti
Thanks for the response, I have tried that option but it is expecting the proper file name in nlmodule.
Thank you!
Views
Replies
Total Likes
Hi @ukender ,
You can use the command: ls -la to list all the files.
Once you have the name and number of files, run the loop to pick each file name and then execute your command.
What is your purpose to run this command? May be you can use some alternative suggestion as well.
Thanks,
Jyoti
Views
Replies
Total Likes
Hi Jyoti
Trying to import / export the package files thru workflow using nlserver module. It is perfectly working if we define a single file for import from sftp location but finding difficulties to fetch multiple files, tried the below options but no success.
Able to write the file names using JS activity after the file collector but unsure how to feed multiple files to nlserver module.
package -instance: [instance_name] -import:sftp/adobe/export/*.xml -verbose
package -instance: [instance_name] -import:sftp/adobe/export/*.* -verbose
Thank you!
Views
Replies
Total Likes
Hi @ukender ,
Even if you are able to read all the files at once, you will be able to process one file at a time. So instead of using nlserver module, you can use:
1) File Collector activity which will pick the file. Once file is picked move them to different location. Also, check "Stop as soon as file is processed". This will make sure to stop once all the files are read and imported.
2) Test activity to check if there's any file present to import.
3) Data Loading activity which will read the files coming from File Collector.
4) Load data of the file.
5) Loop back the workflow to File Collector.
Thanks,
Jyoti
Views
Replies
Total Likes
Hi Jyoti
Thank you for the details. For importing the xml package (deployment package file), I guess we need to use nlserver module. Any lead how to pass multiple values into the nlserver module that would give a solution for the issue.
The first 2 steps are present in the workflow but unsure how to loop the file names in nlserver module and execute multiple times.
Thank you!
Views
Replies
Total Likes
Hi Ukender,
Did you try the File transfer activity.
Thanks,
Adithya
Views
Replies
Total Likes
Hi Adithya,
Thanks for the response, would like to understand how to count the number of files available in the directory and feed the xml name dynamically in nlserver module.
Thank you!
Views
Replies
Total Likes
Hi Ukender,
Not sure if you have to really use the nlserver module for SFTP things.
Can you check if you can use something like below in JS
logInfo(execCommand("ls -ls /usr/local/neolane.../<your directory to search for the files>"))
Thanks,
Adithya
Views
Replies
Total Likes
Hi @ukender ,
If the purpose is to export packages, then I think you may be able to use the JS code. I had defined my packages in package definition. So the following code would export packages in package definition one by one. We can filter out any packages based on the namespace or package name.
var query = xtk.queryDef.create( <queryDef schema="xtk:specFile" operation="select"> <select> <node expr="@name"/> <node expr="@namespace"/> <node expr="data"/> </select> </queryDef> ); var res = query.ExecuteQuery(); var exported = 0; for (var i = 0;i<Object.keys(res).length; i++){ logInfo("Exporting Package " + res[i].@name + " to xml"); if(res[i].@namespace == "cus") { try{ var specFile = xtk.specFile.create(res[i]); var package = specFile.GenerateDoc(); var fileName = "<SFTP path>/PKG_" + res[i].@name.toLowerCase() + ".xml"; saveXmlFile(package, fileName); exported++; }catch(err){ logWarning("Package " + res[i].@name + "has not been exported due to an error."); } } else { continue; } }
Thank you for your inputs @Krishnanunni. I will try that option, Is it possible to import the exported xml package from an SFTP location?
If you have an idea pls share it, would be really helpful.
Thank you!
Views
Replies
Total Likes
@ukender ,
I haven't used it but the xtk.builder InstallPackage function might be useful for this. Please see the below function:
https://experienceleague.adobe.com/developer/campaign-api/api/sm-builder-InstallPackage.html.
You may try reading the xml file and passing the content to the installpackage function.
Hi @ukender,
Were you able to resolve this query with any of the given solutions or do you still need more help here? Do let us know.
Thanks!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies