How to Import Multiple Files through Anaplan Connect?

Hello,

 

I hope you're all doing fine. 

 

I would like to seek help on  this issue that I'm currently having a challenging time accomplishing. 

 

I am using Anaplan Connect basic Import authentication. 

I am successful  running the script when only one file is in the script. 

If I tried to include two files in the script, it is not recognizing the other one. 

It is possible that I'm going to use the script and there will be a lot of files to be imported come production. 

Is it possible? Please help.

 

Below is the script that I'm using with basic authentication, this is working fine. 

But how can I include additional file in the script?

 

@echo off
rem For Windows OS : This example explains the usage of basic Authentication with Anaplan Connect.
rem It also loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script visit https://help.anaplan.com/anapedia/Content/Downloads/DL_Downloads.html

set AnaplanUser="myusername:mypassword"
set WorkspaceId="myworspaceid"
set ModelId="mymodelid"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set FileName="file1.csv"
set FilePath="C:\Users\myprofile\desktop\file1.csv"
set ImportName="Import File 1"
set DumpName="C:\Users\myprofile\Desktop\ANAPLAN CONNECT\Anaplan Connect Import"
set Chunksize=1

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file %FileName% -put %FilePath% -import %ImportName% -execute -output %DumpName%

rem * End of settings - Do not edit below this line *

setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% %Operation%
@echo %Command%
cmd /c %Command%
pause

 

==========================================================

I tried the below script in attempt to include another file in the import but it only processed the file2:

 

@echo off
rem For Windows OS : This example explains the usage of basic Authentication with Anaplan Connect.
rem It also loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script visit https://help.anaplan.com/anapedia/Content/Downloads/DL_Downloads.html

set AnaplanUser="myusername:mypassword"
set WorkspaceId="myworkspaceid"
set ModelId="mymodelid"
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set FileName="file1.csv"
set FilePath="C:\Users\myprofile\desktop\file1.csv"
set ImportName="Import file1"
set FileName="file2.csv"
set FilePath="C:\Users\myprofile\Desktop\file2.csv"
set ImportName="Import File 2"
set DumpName="C:\Users\jspas\Desktop\ANAPLAN CONNECT\Anaplan Connect Import"
set Chunksize=1

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file %FileName% -put %FilePath% -import %ImportName% -execute -output %DumpName%

rem * End of settings - Do not edit below this line *

setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% %Operation%
@echo %Command%
cmd /c %Command%
pause

 

 

Thanks a lot in advance...

Best Answer

  • The script will still need adjusting to upload multiple files, even if a process is used. The reason your script doesn't work is because you are overwriting variables instead of setting new ones and extending the Operation:

    set File1Name="file1.csv"
    set File1Path="C:\Users\myprofile\desktop\file1.csv"
    set Import1Name="Import file1"
    set Dump1Path="C:\Users\myprofile\desktop\file1-dump.csv"
    set File2Name="file2.csv"
    set File2Path="C:\Users\myprofile\Desktop\file2.csv"
    set Import2Name="Import File 2"
    set Dump1Path="C:\Users\myprofile\desktop\file2-dump.csv"
    set Chunksize=1
    set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file %File1Name% -put %File1Path% -file %File2Name% -put %File2Path% -import %Import1Name% -execute -output %Dump1Path% -import %Import2Name% -execute -output %Dump2Path%

    Note that two dump files are required, one for each import. With a process you specify a folder path to -output instead.

Answers

  • @jspascual 

     

    I think you should use Set ProcessName instead of Set ImportName because Import will upload only one underlying file. Create a process in Anaplan Model and use that process in your script and it will take as many import files as there are import actions in your process. This is applicable when your target remains same for these import files and if you targets are not same then there will have to be multiple scripts

     

    Hope that helps

    Misbah 

  • Thank you so much for all your assistance, @ben_speight , @Misbah , it is working now.

     

    This will be helping a lot in the future. 

     

    Aside from what has been suggested, I needed to tweak the script with the below:

     

    set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file "FILE1.csv" -put "C:\Users\MYPROFILE\Desktop\FILE1.csv" -import "IMPORT FILE 1" -execute -output "C:\Users\MYPROFILE\Desktop\Anaplan Connect Import"
    set Operation=%Operation% -execute -file "FILE 2.csv" -put "C:\Users\MYPROFILE\Desktop\FILE 2.csv" -import "IMPORT FILE 2" -execute -output "C:\Users\MYPROFILE\Desktop\Anaplan Connect Import"

     

    All is good. Again, thank you so much! 🙂

     

    Jonathan

  • You don't want that first -execute in the second (appending) line - it will cause the first import to be run a second time.

  • You're awesome, @ben_speight ! Thanks a lot... That's why I was wondering why the first schedule was running twice... but it didn't bother me since it was just overriding what's in that period/month. However, considering there might be few more schedules to incorporate on the script, it might affect the performance in the long run. I removed the -execute for the next two schedules from the script and it worked. Thanks, I'm learning a lot. 🙂

     

    Jonathan

  • @ben_speight @Misbah ,

     

    Can you help with script format where process can be used in this case? The process might not have just have two imports actions to import two files into the same model but other actions like adding list member or importing data from one module to other module will be part of this process. Just trying to understand if it would work in this case as well and sample script would help.

  • @Fayazs117280 ,

     

    So it is best to upload the files and then run the actions off the files per model.  So, this was not done correctly, but you will get the point.  The -import or if it is a process (-p) would be after all of the -put commands.

     

    2020-07-30_16-31-24.png

     

    And when you switch model or workspace, you just connect to that from within the same Anaplan Connect script:

     

    Set the variables:

    2020-07-30_16-39-27.png

     and then, using the variables in the Operation line

    2020-07-30_16-34-31.png

     

    and then at the bottom of my script, I changed it so it would bring in all of the commands

    2020-07-30_16-42-20.png

     

    Hope this helps,

     

    Rob

     

  • Thanks @rob_marshall , this helps. Would we still need -import even if this import action is already part of the process. So in your case, would -import " Resources from Resources.csv" is required if this import action is already part of your process -process "Get All SFDC Data" ?

     

    Just the -process wouldn't do the -import thing.

  • @Fayazs117280 ,

     

    No, the process would do the import for you.

  • @rob_marshall 

     

    I was trying to do the same, however the process and actions under it are getting execute but the records not being updated or added. File not being imported

     

     

     

  • @Fayazs117280 

     

    would need to see the log to know for sure.  Can you paste that or take a picture and post it?  One issue you might be having is the name of the file you are posting.  If it is not the same as what the action is tied to, then the "original" file will not get updated and thus the import of the new data will not work.

     

    For example, when the model builder originally defined the action, it was "tied" to "Actuals_Jan.csv".  Well, if you are now loading "Actuals_Feb.csv", the action will run, but it will run the file from Jan which is why we do not advocate have file names that could change.  In order to see which actions are tied to which source, in Anaplan, go to Actions and choose the Import Sources tab

     

    2020-07-31_12-38-34.png

     

    Hope this helps,

     

    Rob