Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonathan Roberts 409 posts 1063 karma points
    May 26, 2015 @ 15:28
    Jonathan Roberts
    0

    4.1.2 Prevalue Sources break CMS Forms

    Hi, We have upgraded our Umbraco CMS 7.2.4 with Contour 4.1.2 and if we add ANY Prevalue source (such as a Yes/No datatype - for example) to a drop down we can't view the form once we have saved it. On further inspection we get the following errors:

    )]}', {"Message":"An error has occurred.","ExceptionMessage":"Incorrect syntax near the keyword 'order'.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":" at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\r\n at System.Data.SqlClient.SqlDataReader.get_MetaData()\r\n at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\r\n at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)\r\n at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters)\r\n at umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper.ExecuteReader(String commandText, SqlParameter[] parameters)\r\n at umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters)"}

    LOG FILE ERROR: 2015-05-26 14:19:16,453 [6] ERROR umbraco.DataLayer.SqlHelper1[[System.Data.SqlClient.SqlParameter, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] - [Thread 28] Error executing query Select id, [value], sortorder from cmsDataTypePreValues where DataTypeNodeId = order by sortorder System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'order'. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper.ExecuteReader(String commandText, SqlParameter[] parameters) at umbraco.DataLayer.SqlHelper1.ExecuteReader(String commandText, IParameter[] parameters) ClientConnectionId:f2be27dc-6cda-4882-9c5b-7928c089c318 Error Number:156,State:1,Class:15

  • Comment author was deleted

    May 26, 2015 @ 15:29

    Thanks for the details, taking a look now

  • Comment author was deleted

    May 26, 2015 @ 15:34

    Ok can confirm the issue, happens when you use the "Umbraco data type" prevalue source type

    Looking into the fix now, should have an update ready later today

  • Comment author was deleted

    May 26, 2015 @ 15:44

    Ok found the error, just doing some final testing and I'll push out a new nightly that you can upgrade to

  • Comment author was deleted

    May 26, 2015 @ 15:58

    COuld you update to the following nightly http://nightly.umbraco.org/UmbracoForms/nightlies/UmbracoForms.Files.4.1.3-WIP.Build.50.zip

    The download is an archive that you'll need to extract and use to replace the existing form files

    Let me know if that fixes the issue

  • Jonathan Roberts 409 posts 1063 karma points
    May 26, 2015 @ 16:08
    Jonathan Roberts
    0

    Hi Tim, Many thanks for looking into this - fantastic response. We have updated our files with your attached. We can now view the forms but the prevalue options in the drop down are duplicated once you save the form For example: Save the form > leave the form > then view the form again.

    Hope this makes sense, Jon

  • Comment author was deleted

    May 26, 2015 @ 16:09

    Ok makes sense :) how do they look on the rendered forms on the frontend also duplicate?

  • Jonathan Roberts 409 posts 1063 karma points
    May 26, 2015 @ 16:15
    Jonathan Roberts
    0

    HI, It looks ok on the front end - it only duplicates when the form opens in edit mode (CMS).

    Jon

  • Comment author was deleted

    May 26, 2015 @ 16:16

    Ok thanks for the additional info, I can also reproduce the same behaviour, looking into a fix

  • Comment author was deleted

    May 26, 2015 @ 16:51

    Fixed you can upgrade to: http://nightly.umbraco.org/UmbracoForms/nightlies/UmbracoForms.Files.4.1.3-WIP.Build.51.zip

    Let me know if that does the trick :)

     

  • Jonathan Roberts 409 posts 1063 karma points
    May 29, 2015 @ 10:09
    Jonathan Roberts
    0

    Hi, Sorry for the late response. Many thanks for all your effort on fixing this.

    We have found another little issue - when passing a date through we have noticed that the date has a Backslash and a Forward slash, for example 03\/02\/2015 so if we parse this into a datetime it fails.

    On further investigation it looks like any thing that has a Forward slash it is escaping it with a backslash - so any HTML has backslashes in the markup too.

    I Hope this makes sense,

    Jon

  • Comment author was deleted

    May 29, 2015 @ 10:19

    Ok thanks for the details Jonathan, I'll take a look

  • Comment author was deleted

    May 29, 2015 @ 13:54

    Could you provide some more steps on how to reproduce? Tried inputting a date and it worked fine..  so any more steps you can provide will be usefull :) thanks!

  • Jonathan Roberts 409 posts 1063 karma points
    May 29, 2015 @ 14:07
    Jonathan Roberts
    0

    Hi, My apologies, we did a bit more investigation and it appears to only exist when we create a Workflow to do stuff with the data. For example:

      foreach (RecordField rf in record.RecordFields.Values)
                {
                    var fieldValue = rf.ValuesAsString();}
    

    Does this help?

    Many thanks

  • Comment author was deleted

    May 29, 2015 @ 14:09

    Ok will take a look, thanks

  • Chris Wilson 100 posts 377 karma points
    May 29, 2015 @ 15:49
    Chris Wilson
    0

    Hi Jonathan,

    I had the same issue when attempting to retrieve URLs from ValuesAsString(), try using the following method instead and see if you get the same results:

            var fieldValue = rf.Values.Where(v => v != null).Select(v => v.ToString()).FirstOrDefault();
    

    That fixed it for me.

    If you're expecting multiple values you can add a method to concatenate them:

    private static string GetStringFromFieldValues(IRecordField field)
        {
            // Guard clauses
            if (field == null) return null;
    
            // Get the array of potential values
            var strArr = field.Values.Where(v => v != null).Select(v => v.ToString()).ToList();
    
            // Get all available strings from the array
            if (strArr.Count == 1) return strArr.FirstOrDefault();
            if (strArr.Count > 1) return string.Concat(strArr);
    
            return null;
        }
    

    Regards, Chris

  • Jonathan Roberts 409 posts 1063 karma points
    May 29, 2015 @ 15:55
    Jonathan Roberts
    0

    Thanks for the update Chris, but this didn't fix our issue. Sorry :(

    Jon

  • Jonathan Roberts 409 posts 1063 karma points
    Jun 01, 2015 @ 10:06
    Jonathan Roberts
    0

    Hi, Is this still under development?

  • Comment author was deleted

    Jun 01, 2015 @ 10:07

    Yup looking at it this morning, so will have an update for you a bit later

  • Comment author was deleted

    Jun 01, 2015 @ 10:09

    IF you are parsing to datetime why do you need them as string, since rf.Values will contain them in the correct type...

  • Jonathan Roberts 409 posts 1063 karma points
    Jun 01, 2015 @ 10:14
    Jonathan Roberts
    0

    We could use a linq statement to get the type but it would mean doing one for each type. It also does it for HTML so and tag such as would look like <\/strong>.

  • Comment author was deleted

    Jun 01, 2015 @ 10:15

    Ok thanks for the details

  • Comment author was deleted

    Jun 01, 2015 @ 10:29

    Well the valuesasstring is used in the records viewer and that records viewer uses json so we need to escape those chars...

    But like mentions you can just write your own method to perform the convertion without escaping...

    so the code that we are using is

     

    string.Join(", ", Values.ConvertAll<string>(obj => JsonHelper.EscapeStringValue(obj.ToString())).ToArray());

    you could use 

     

    string.Join(", ", Values.ConvertAll<string>(obj => obj.ToString()).ToArray());

Please Sign in or register to post replies

Write your reply to:

Draft