SharePoint 365 SPD Workflow Dictionary default date format issue

%3CLINGO-SUB%20id%3D%22lingo-sub-56484%22%20slang%3D%22en-US%22%3ESharePoint%20365%20SPD%20Workflow%20Dictionary%20default%20date%20format%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56484%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20building%20a%20SharePoint%20Designer%20workflow%20which%20uses%20the%20Call%20HTTP%20Web%20Service%20action.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20list%20that%20contains%20an%20%3CEM%3Eoptional%3C%2FEM%3E%20date%2Ftime%20field%20called%20'Deadline'.%3C%2FP%3E%3CP%3EI've%20added%20this%20field%20to%20a%20Dictonary%20using%20the%20Value%20%3CEM%3ECurrent%20Item%3A%20Deadline%3C%2FEM%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20action%20updates%20a%20list%20item.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20the%20Deadline%20field%20has%20been%20set%20by%20a%20user%2C%20the%20Update%20request%20parameters%20contain%20the%20following%20JSON%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22Deadline%22%3A%222017-03-30T23%3A00%3A00.0000000Z%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20the%20Deadline%20field%20has%20not%20been%20set%2C%20I%20can%20see%20that%20the%20Deadline%20feild%20is%20returned%20as%20null%20using...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E..._api%2Fweb%2Flists%2Fgetbytitle('ListName')%2Fitems%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%26lt%3Bd%3ADeadline%20m%3Anull%3D%22true%22%20%2F%26gt%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%2C%20when%20the%20REST%20api%20Update%20request%20is%20built%2C%20the%20parameters%20Dictionary%20appears%20to%20be%20setting%20a%20default%20date.%20It%20appears%20thus%20in%20the%20JSON%20request...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22Deadline%22%3A%220001-01-01T00%3A00%3A00.0000000%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20causes%20the%20Update%20request%20to%20fail...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResponse%20Content%3A%20%7B%22error%22%3A%7B%22code%22%3A%22-2130575155%2C%20Microsoft.SharePoint.SPFieldValueException%22%2C%22message%22%3A%7B%22lang%22%3A%22en-US%22%2C%22value%22%3A%22Cannot%20complete%20this%20action.%5Cu000a%5Cu000aPlease%20try%20again.%22%7D%7D%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResponse%20Code%3A%20BadRequest%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20advise%20a%20way%20to%20mitigate%20this%20behaviour%3F%3C%2FP%3E%3CP%3EMy%20attempts%20to%20check%26amp%3Breact%20to%20the%20status%20of%20the%20Datetime%20field%20are%20unsuccessful.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3ETony%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-56547%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20365%20SPD%20Workflow%20Dictionary%20default%20date%20format%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-56547%22%20slang%3D%22en-US%22%3E%3CP%3EOk%2C%20not%20Ideal%20but...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3EIf%20Current%20Item%3A%20Deadline%20is%20less%20than%20or%20equal%20to%2001%2F01%2F2001%2000%3A00%3A00%0A%20%20%20Build%20%7B...%7D%20Dictionary(Output%20to%20Variable%3A%20Update_Parameters)%0A%20%20%20**%20but%20don't%20include%20the%20Deadline%20field%20as%20a%20parameter%20**%0AElse%0A%20%20%20Build%20%7B...%7D%20Dictionary(Output%20to%20Variable%3A%20Update_Parameters)%20%0A%20%20%20**%20but%20do%20include%20the%20Deadline%20field%20as%20a%20parameter%20**%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps%20someone.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20great%20that%20you%20can%20copy%2Fpaste%20the%20Build%20Dictionary%20actions%20within%20SPD.%3C%2FP%3E%3CP%3EIt's%20a%20shame%20they%20empty%20their%20contents%20as%20thay%20are%20copied.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20the%20way...%3C%2FP%3E%3CP%3EI'm%20doing%20this%20as%20moving%20Document%20Sets%20with%20the%20REST%20api%20(...folder%2FMoveTo(newUrl))turns%20them%20into%20regular%20folders.%3C%2FP%3E%3CP%3Ei.e.%20they%20lose%20their%20Content%20Type%20Id%20in%20transit.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOnce%2C%20I've%20moved%20them%2C%20I%20update%20them%20with%20correct%20Content%20Type%20and%20the%20properties%20of%20the%20original.%3C%2FP%3E%3CP%3EWhich%20reverts%20them%20back%20to%20the%20Documents%20Set%20I%20expect.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheers%2C%3C%2FP%3E%3CP%3ETony%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1057252%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20365%20SPD%20Workflow%20Dictionary%20default%20date%20format%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1057252%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F45921%22%20target%3D%22_blank%22%3E%40Tony%20Hignett%3C%2FA%3E%26nbsp%3BI've%20come%20across%20this%20too.%26nbsp%3B%20Could%20have%20sworn%20it%20was%20working%20before%20without%20requiring%20the%20workaround.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20I%20had%20multiple%20date%5Ctime%20fields%2C%20I%20chose%20to%20remove%20all%20of%20them%20from%20the%20main%20dictionary.%26nbsp%3B%20Then%20I%20created%20a%20dictionary%20per%26nbsp%3Bdate%5Ctime%20field%20and%20ran%20the%20REST%20call%20inside%20each%20IF%20statement.%26nbsp%3B%20Too%20bad%20there%20is%20no%20way%20to%20dynamically%20add%20fields%20to%20a%20Dictionary%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi All,

 

I'm building a SharePoint Designer workflow which uses the Call HTTP Web Service action.

 

I have a list that contains an optional date/time field called 'Deadline'.

I've added this field to a Dictonary using the Value Current Item: Deadline.

 

The action updates a list item.

 

When the Deadline field has been set by a user, the Update request parameters contain the following JSON:

 

"Deadline":"2017-03-30T23:00:00.0000000Z"

 

When the Deadline field has not been set, I can see that the Deadline feild is returned as null using...

 

..._api/web/lists/getbytitle('ListName')/items

 

<d:Deadline m:null="true" />

 

But, when the REST api Update request is built, the parameters Dictionary appears to be setting a default date. It appears thus in the JSON request...

 

"Deadline":"0001-01-01T00:00:00.0000000"

 

This causes the Update request to fail...

 

Response Content: {"error":{"code":"-2130575155, Microsoft.SharePoint.SPFieldValueException","message":{"lang":"en-US","value":"Cannot complete this action.\u000a\u000aPlease try again."}}}

 

Response Code: BadRequest

 

Can anyone advise a way to mitigate this behaviour?

My attempts to check&react to the status of the Datetime field are unsuccessful.

 

 

Thanks,

Tony

2 Replies
Highlighted

Ok, not Ideal but...

 

If Current Item: Deadline is less than or equal to 01/01/2001 00:00:00
   Build {...} Dictionary(Output to Variable: Update_Parameters)
   ** but don't include the Deadline field as a parameter **
Else
   Build {...} Dictionary(Output to Variable: Update_Parameters) 
   ** but do include the Deadline field as a parameter **

 

Hope this helps someone.

 

It's great that you can copy/paste the Build Dictionary actions within SPD.

It's a shame they empty their contents as thay are copied.

 

By the way...

I'm doing this as moving Document Sets with the REST api (...folder/MoveTo(newUrl))turns them into regular folders.

i.e. they lose their Content Type Id in transit.

 

Once, I've moved them, I update them with correct Content Type and the properties of the original.

Which reverts them back to the Documents Set I expect.

 

Cheers,

Tony

Highlighted

@Tony Hignett I've come across this too.  Could have sworn it was working before without requiring the workaround.

 

As I had multiple date\time fields, I chose to remove all of them from the main dictionary.  Then I created a dictionary per date\time field and ran the REST call inside each IF statement.  Too bad there is no way to dynamically add fields to a Dictionary