Anaplan Connect - Use of Certificate in script does not work

Occasional Contributor

Anaplan Connect - Use of Certificate in script does not work

Hello,

 

I have the following script written up to update a module to hold Today's date and time.

The script worked fine when I was using my username and was prompted for the password.

As I am looking to schedule this script everyday, I want ahead and downloaded the certificate linked to my user and changed the script as seen on user guides. 

However I still get prompted for a password.  

Can someone please help me?

 

This is the script:

@echo off

set AnaplanUser="anaplanadmin@withings.com"
set WorkspaceId="8a81b09457ee03b601581c074c2a04e2"
set ModelId="C0A17C7D902343359BA909CCD3D3DC7E"
set Operation -certificate "C:\Users\Elisa\Documents\certificate-222628677637089600518301929753078471363.cer" -export

:: This script looks up the current date, writes it to a csv file, and sends it to Anaplan
:: Here we set the file path of the csv file we will be writing the current date too

set FileName="C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\CurrentDate.csv"


:: rem This is a simple for loop that parses the date /t function

FOR /f "tokens=1,2,3 delims=-" %%a in ('date /t') do (set mm=%%b& set dd=%%c& set yyyy=%%a)

set mydate=%yyyy%%mm%%dd%

@echo "Current Date","Heure"> %FileName%

@echo "%mydate%","%TIME%">> %FileName%

set Operation=-file "CurrentDate.csv" -put %FileName% -import "Today from CurrentDate.csv" -execute -output "C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\Errors"


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% -workspace %WorkspaceId% -model %ModelId% %Operation%

@echo %Command%

cmd /c %Command%

pause

Message 1 of 8
7 REPLIES 7
Community Boss

Re: Anaplan Connect - Use of Certificate in script does not work

Hi Elisa,

 

Towards the end of the batch script, replace the following:

if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%

 

With this;
if not %certificate% == "" set Credentials=-certificate %certificate%

 

It should work fine. If required refer the attached script.

 

@echo off
rem This example loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script see doc\Anaplan Connect User Guide.doc

set certificate="C:\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\certificate-262107658004671057091197622572827278496.cer"
set WorkspaceId="workspace id"
set ModelId="model id"
set Operation= -export "Avg Calculations - Total.csv" -execute


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

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

 

 

Hope this helps.

 

Regards,

Pavan

Message 2 of 8
Occasional Contributor

Re: Anaplan Connect - Use of Certificate in script does not work

Hello,

 

Thank you for your help. Unfortunately it is still not working.

I set up my script just like your example. 

Is there something particular I should be doing with the certificate maybe?

 

New script:

@echo off

set certificate="C:\Users\Elisa\Documents\certificate-222628677637089600518301929753078471363.cer"
set WorkspaceId="8a81b09457ee03b601581c074c2a04e2"
set ModelId="C0A17C7D902343359BA909CCD3D3DC7E"
:: This script looks up the current date, writes it to a csv file, and sends it to Anaplan
:: Here we set the file path of the csv file we will be writing the current date too

set FileName="C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\CurrentDate.csv"
:: rem This is a simple for loop that parses the date /t function

FOR /f "tokens=1,2,3 delims=-" %%a in ('date /t') do (set mm=%%b& set dd=%%c& set yyyy=%%a)

set mydate=%yyyy%%mm%%dd%

@echo "Current Date","Heure"> %FileName%

@echo "%mydate%","%TIME%">> %FileName%

set Operation=-file "CurrentDate.csv" -put %FileName% -import "Today from CurrentDate.csv" -execute -output "C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\Errors"
rem *** End of settings - Do not edit below this line ***

setlocal enableextensions enabledelayedexpansion || exit /b 1

cd %~dp0

if not %certificate% == "" set Credentials=-certificate %certificate%

set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%

@echo %Command%

cmd /c %Command%

pause

Message 3 of 8
Community Boss

Re: Anaplan Connect - Use of Certificate in script does not work

Oh.

To your previous script, just replace the follwing line 

if not %certificate% == "" set Credentials=-certificate %certificate%

 

and try.

 

Regards,

Pavan

Message 4 of 8
Occasional Contributor

Re: Anaplan Connect - Use of Certificate in script does not work

Hello,

 

I did and its the same result, that's why I tried again with sticking to your example:

 

This is the script with just the change you mentionned:

The script here, updates a file with today's date and then tries to import it to Anaplan. The updating file part works, but there is no import in Anaplan.

 

@echo off

set AnaplanUser="anaplanadmin@withings.com"
set WorkspaceId="8a81b09457ee03b601581c074c2a04e2"
set ModelId="C0A17C7D902343359BA909CCD3D3DC7E"
set Operation -certificate "C:\Users\Elisa\Documents\certificate-222628677637089600518301929753078471363.cer" -export


:: This script looks up the current date, writes it to a csv file, and sends it to Anaplan
:: Here we set the file path of the csv file we will be writing the current date too

set FileName="C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\CurrentDate.csv"


:: rem This is a simple for loop that parses the date /t function

FOR /f "tokens=1,2,3 delims=-" %%a in ('date /t') do (set mm=%%b& set dd=%%c& set yyyy=%%a)

set mydate=%yyyy%%mm%%dd%

@echo "Current Date","Heure"> %FileName%

@echo "%mydate%","%TIME%">> %FileName%

set Operation=-file "CurrentDate.csv" -put %FileName% -import "Today from CurrentDate.csv" -execute -output "C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\Errors"


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

 

setlocal enableextensions enabledelayedexpansion || exit /b 1

cd %~dp0

if not %certificate% == "" set Credentials=-certificate %certificate%

set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%

@echo %Command%

cmd /c %Command%

pause

Message 5 of 8
Community Boss

Re: Anaplan Connect - Use of Certificate in script does not work

Okay. If tht's the case, can you try the script in following manner:

 

@echo on
:: This script looks up the current date, writes it to a csv file, and sends it to Anaplan

:: Here we set the file path of the csv file we will be writing the current date too

set FileName="E:\anaplan-connect\CurrentDate.csv"

:: rem This is a simple for loop that parses the date /t function
FOR /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set mm=%%a& set dd=%%b& set yyyy=% %c& (if "%%a:~0,1" gtr "9" set mm=%%b& set dd=%%c& set yyyy=%%d))

echo Todays date in Windows format is: %date%

set mydate=%yyyy%-%mm%-%dd%

echo 'Current Date': %mydate%

rem The following is not needed unless you have specific requirements to strip characters, etc
:: rem Remove leading Zeros from Day
:: set d=%dd%
:: set /a d=100%d% %% 100
:: rem Remove leading Zeros from Month
:: set m=%mm%
:: set /a m=100%m% %% 100
:: set snapshot=%d%-%m%-%yyyy%

set snapshot=%mydate%
echo 'Latest Snapshot': %snapshot%

@echo "Current Date","Latest Snapshot"> %FileName%
@echo "%mydate%","%snapshot%">> %FileName%

rem **************************************************************

rem This example loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script see doc\Anaplan Connect User Guide.doc

set certificate="E:\anaplan-connect\certificate-304882231934460512329172813723037634997.cer"
set WorkspaceId="workspace id"
set ModelId="model id"
set Operation= -file "CurrentDate.csv" -put %FileName% -import "Import todays date" -execute

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

setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %certificate% == "" set Credentials=-certificate %certificate%
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%

 

 

 

Regards,

Pavan

Message 6 of 8
Occasional Contributor

Re: Anaplan Connect - Use of Certificate in script does not work

Thank you so much for your help Pavan!

 

It worked after a little change from your last script.

In the end this is the scrip that works in case this might help people:

 

@echo on
:: This script looks up the current date, writes it to a csv file, and sends it to Anaplan
:: Here we set the file path of the csv file we will be writing the current date too

set FileName="C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\CurrentDate.csv"
:: rem This is a simple for loop that parses the date /t function

FOR /f "tokens=1,2,3 delims=-" %%a in ('date /t') do (set mm=%%b& set dd=%%c& set yyyy=%%a)

set mydate=%yyyy%%mm%%dd%

@echo "Current Date","Heure"> %FileName%

@echo "%mydate%","%TIME%">> %FileName%

set Operation=-file "CurrentDate.csv" -put %FileName% -import "Today from CurrentDate.csv" -execute -output "C:\Users\Elisa\Downloads\anaplan-connect-1-3-3-5\anaplan-connect-1-3-3-5\Errors"
rem **************************************************************

rem This example loads a source text file and runs an Anaplan import into a module.
rem For details of how to configure this script see doc\Anaplan Connect User Guide.doc

set certificate="C:\Users\Elisa\Documents\certificate-222628677637089600518301929753078471363.cer"
set WorkspaceId="8a81b09457ee03b601581c074c2a04e2"
set ModelId="C0A17C7D902343359BA909CCD3D3DC7E"
set Operation= -file "CurrentDate.csv" -put %FileName% -import "Today from CurrentDate.csv" -execute

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

setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %certificate% == "" set Credentials=-certificate %certificate%
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@echo %Command%
cmd /c %Command%

Message 7 of 8
Highlighted
Community Boss

Re: Anaplan Connect - Use of Certificate in script does not work

Cheers
Message 8 of 8