Seiten

Donnerstag, 7. Januar 2016

Sharepoint 2013 Online Workflow - Get current Time and Date

Hi,

at the moment I'm working very much with Sharepoint 2013 Online and - thank god - I have access to the SharepointDesigner.

Background

I was trying to create a workflow which had the purpose to check a list of treatys. If they run out of time, they may need to be quit. This workflow runs once a day forever (simple infinity loop). 

It wasn't very beautiful, that the workflow has started every day on the same time I started the workflow the first time (9 o'clock in the morning). Looking in the future, the amount of treatys will raise. Therefor using the resources of sharepoint during the daybusiness, is not very helpful. Yes of course, I could wake up in the middle of the night an start the workflow once but this solution is too simple and not cool.

So I was looking for a possibility to trigger the workflow by time. Specify the starting time isn't complicated. You can specify it using a sharepint list and capture the entry by the workflow or just set a workflow variable with the specific time.

But, the workflow still not knows the current time and date.


Solutions of the Web

I found some solutions on the web but they weren't very helpful for my situation. Why? Well, the workflow willl never ends. he will always run. Therefor it is necessary it requires less ressources and produces less amount of data or using less memory. 
  • One solution was to create or modify a dummy file and capture the datetime of creation/ modification. 
  • the second solution suggests to create a history log entry with an unique description. Then the workflow has to capture the creation date of the log entry. Well this would work but considiring my problem, the system would create one log entry each day. That means 365 - btw 366 in this year 2016 - entries each year would be stored in the system. I haven't figured out how to delete them. Maybe it is very easy.

My Solution

I found the following blog entry of Chris Wellons. He describes his problem that he doesn't trust the local system time and wanted to get the time and date from a different source.
He describes some services which offered an API to get time and date as well as some  services using JSONP but they are alredy down.

Then Mr. Wellsons had an "heureka": 
"This is when the lightbulb went off: web servers hand out date strings all the time! It’s a standard HTTP header: Date!"
Now we are in business. 
Building Workflows using the SharePoint Designer, it offeres the action "Call HTTP Webservice".
So all we need is calling a GET-Method to a random website, filtering the response for "date" and voilá, we have the current date and time (GMT).

Step by step: 
  1. Reading the specification RFC 2616 Chapter 14.18 (Wikipedia), the respond as well as the request of an HTTP Request contains the date and time of the request as well as of the respond.To check the specification, use Web-Sniffer to see which content your request will have.
    The request to google will respond with the following information:

    The field "Date" ist interesting, because it rovides the information about the current time (GMT) and date.
  2. Open SharePoint Designer and create a new Workflow 2013, not 2010.
  3. Create a new dictionary
  4.  Add the following elements:
    I'm not sure, if this is necessary but it will work.
  5. Store the Output in a new variable of the type "dictionary" and name it "dictionary"
  6. Create "Call HTTP-WebService"-Action
  7. Click on "This" and add the webservice. To be mentioned: I don't want to get the content of the webservice. I'm only interested in the meta information. Therfore i used the follwoing third party service to transform the respons in propper JSON style: http://www.firstamong.com/json/index.php?q=
    This is a suggestion by HyongGuk Kim. We add http://www.google.de to the adress and write it to the HTTP Call. The HTTP-Method is set to "HTTP Get".
  8.  The respond has to be stored somewhere. Therefor we store it in a variable "Header" of the type "dictionary".
  9. Furthermore we have to set a variable of the type "dictionary" to tore the respond output for "RespnseStatusCode". But we will not need it. The Software will create an error, if no variable is set.
  10. Click with your right moue button on the "Call HTTP-Webservice"-Action and choose "properties". Set the dictionary we created in step 3 to "Request Header" like shown in the following picture:
  11. Now first test it. Add "Send Mail"-Action and send it to your self with the content of the variable "Header". Save and publish your workflow and start it.
  12. The variable Header has the following content:



    Using the WebService JSON Parser Online by Olivier Cuenot, you can transform the output of the header in a much better human readable style:



    Now you can see, that "COnnecntion", "Date", "Server" and "X-Powered-By" are arrays containing one field only. Now we can build our parser to get the information from the first field of the array "Date".
  13. Go to your workflow again. Add "Get Item from Dictionary"-Action and write for "item by name or path":
    Date/(0)


    Why? Well Date, Server, Connection,... are all root elements of the type array. Each of them only consits of one element. The first element will be assigned by using the index 0 in brackets. Of course you can get the information about the Server or the Connection on the same way like writing: Server/(0) or Connection/(0) .
  14. The infomration are stored in the variable "Header". Store the output in the variable "Date" of the type "Date and Time".

    Add the variable "Date" to the "Send a Mail"-Action. Looking Up the wrkflow variable, you can retrive the infomration tored in the date variable of the type "date and time" in different format, e.g. long/ short time, long/ short date, string or iso
  15. Finally save and publish yur workflow and start it.
  16. The mail looks like this:

  17. Now we are able to use the current date and time working with a Sharepoint 2013 workflow.
    To be mentioned: You will see that the respond time is in GMT +-0 timezone and the exact time and date stored in the variable date is in GMT +1. Maybe a nice function of Sharepoint? Don't know.
I know that this isn't a very clean solution. Some points arent exactly clear to my self but it works. Therefor I invite you to add explanations and improvements.

Thanks for reading.


//Edit 17.02.2016:
Meanwhile I have extracted the solution to an seperate website workflow which starts every day at 00:01 and waits 24h until it starts again. The website workflow determines the actual date and write it to a seperate list. In this list i use calculated columns to determine the date of yesterday, of tomorrow as well as the last and the next year.

  

References

  • http://nullprogram.com/blog/2013/05/11/ , 07.01.2016 
  • http://www.wonderlaura.com/Lists/Posts/Post.aspx?ID=224 , 07.01.2016
  • http://blogs.msdn.com/b/sridhara/archive/2014/08/21/fix-sharepoint-2013-workflow-recursion-prevention-part-2.aspx ,  07.01.2016
  • https://de.wikipedia.org/wiki/Liste_der_HTTP-Headerfelder#Antwort-Headerfelder , 07.01.2016
  • http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 , 07.01.2016
  • https://blogs.msdn.microsoft.com/sharepointdesigner/2012/09/04/how-to-work-with-web-service-using-call-http-web-service-action-in-sharepoint-designer-2013/ , 07.01.2016
  • http://blog.appliedis.com/2014/10/09/sharepoint-designer-2013-workflow-working-with-web-services/ , 07.01.2016
  • http://blogs.evocom.de/af/archive/2013/08/06/sharepoint-2013-workflows-teil-1-call-http-web-service.aspx , 07.01.2016
  • https://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/ , 07.01.2016
  • http://json.parser.online.fr/ , 07.01.2016 

Freitag, 6. Februar 2015

Meine Erfahrung mit MyWirecard 2go Visa

Hallo.
Vor einem Jahr zu Weihnachten habe ich eine MyWirecard 2go Visa Karte geschenkt bekommen. Das ist eine Prepaid Kreditkarte die mit Guthaben aufgeladen wird und dann wie eine fast ganz normale Kreditkarte verwendet werden kann. Da ich ansonsten keine Kreditkarte besitze und auch nicht in Erwägung ziehe eine zu kaufen/ mieten - wie auch immer - eignete sich die Prepaidkarte ideal für die Bezahlung im Google Play Store, der leider noch immer keine Guthabenkarten in Deutschland anbietet (nur über Umwege).
Jedenfalls habe ich diese Karte nach Erhalt auch gleich freigeschaltet. Ein Teil des eigentliches Guthabens wird gleich als Gebühr einbehalten. Für die Benutzung ist kein Name, Anschrift oder Verifizierung notwendig. Nur eine Handynummer muss hinterlegt werden bzw wird bei Freischaltung über SMS wohl hinterlegt.
Das Bezahlen hat immer super geklappt und es gab auch nie Probleme. Zwischendurch habe ich mich immer wieder gefragt was passiert, wenn mein Guthaben aufgebraucht ist und ich trotzdem etwas kaufe. Laut dem Support wird dieser Kauf dann nicht durchgeführt. Abwarten...
Das Jahr näherte sich dem Ende und auch mein Guthaben näherte sich dem Ende. Schließlich überlegte ich mir die Karte verlängern zu lassen. Auf den ersten Blick konnte ich keine Gebühren entdecken die entstehen, wenn man die Karte verlängert. Also seinen Namen mit Anschrift hinterlässt.
Allerdings nach Abschluss der Verlängerung las ich die Gebührenübersicht aus einer anderen Perspektive und ich überlegte ob ich nun durch die Verlängerung der Karte mit Gebühren aufhalste oder nicht. In der Gebührenbersicht heist es...
... dass nach erfolgreicher Freischaltung zur Wiederaufladung je nach Einsatz Gebühren anfallen können. Weiterhin heist es bei Punkt 2 dass man jedes Jahr eine neue Karte bekommt, die mit 9,95€ zu buche schlägt. Auf nachfrage im Chat Support teilte man mir mit, dass diese 9,95€ jetzt anfallen und mit der neuen Karte begleichen werden müssen.
Nunja da Fernabsatzgeschäft besitze ich als Verbraucher ein 14 tägiges Wiederrufrecht und sehe keine Grund warum das hier nicht greifen sollte.
Also habe ich umgehend einen Widerruf per Fax versendet samt Kündigung.
Als Antwort bekam ich die Rückmeldung, dass das verbliebene Guthaben entweder verbraucht werden müsse oder sonst Verwaltungsgebühren anfallen würden. ich wollte auf jedenfall mein restliches Guthaben ausgezahlt bekommen und teite mein Empfängerkonto mit. Darauf wurde mir mitgeteilt, dass eine Überweisung pauschal mit 2,50€ Gebühren zu Buche schlägt. Auf Grund der Höhe des Restguthabens lohnte sich diese Option nicht.
Die Andere Variante bestand darin, selbst das Guthaben zurück zuüberweisen, in dem man sein Bankkonto bei MyWirecard hinterlegt und freischalten lässt. Gesagt getan. Nach paar Tagen war mein Konto hinterlegt und verifiziert und bereit den Restbetrag zurück überweisen zu lassen. Konto ausgewählt, Restbetrag eingegeben... Meldung "Ihr Betrag ist zu gering". Toll super alles umsonst. Also wieder Mail an den Support die mir nur das mitteilte was ich schon wusste. Ausdrücklich auf das Problem hingewiesen dass mein restlichen Guthaben nicht selbst überweisen könne, da der Betrag zu gering sei. jedoch bekam ich dann keine Antwort mehr. Warum auch immer.
Da es schließlich darum ging, das Konto leer zu bekommen, suchte ich mir ein Angebot aus, dass genau diesem Betrag entsprach. Schließlich kaufte ich eine mp3. Jedoch wurde meine aktuell hinterlegte Kreditkartennummer nicht mehr akzeptiert. Achja... ich hatte sie ja zur Wiederaufladung freigeschaltet und hatte eine neue mit neuer Nummer bekommen. Die neue Karte angegeben gekauft fertig. Über die Feiertage bekam ich dann die Meldung seitens Wirecard, ich möge bitte die o.g. 9,95€ begleichen.
Scheiße! Von hinten selbst ins Knie geschossen. Widerruf wurde durch Benutzung der Karte unwirksam. Nunja... in den sauren Apfel gebissen, die Gebühr samt Überweisungsgebühr überwiesen und Fehlbetrag ausgeglichen. Kündigung erneut per Fax abgesendet
Ich kann diese Prepaid Karte nicht empfehlen. Ich finde die Gebühren intransparent und nicht deutlich genug dargelegt. Weiterhin finde ich es merkwürdig keine Möglichkeit zu geben sein restguthaben zurück zurücküberweisen wenn es unter einem bestimmten Betrag liegt. Soweit ich weis müssen Telekommunikationsunternehmen den Restbetrag einer Prepaidkarte auch zurück überweisen bei Kündigung sofern der Kunde dies wünscht. Warum also nicht auch bei einer Prepaid Kreditkarte?
Für den Apple iTunes Store verwende ich nun nur noch ausschließlich Geschenkkarten und für den Google Play Store wird es wohl in nächster zeit auch Geschenkkarten geben oder man bestellt sich welchen in den USA. Für alles andere gibt es PayPal.

Helpful windows commands

Ongoing collection of helpful windows cmd commands.


Shows the IP adress of each device at your local network
arp /a
Starts a program to record each user step to debug problems (no Keylogging/ spyware)
psr