Skip to content

DisableAllFieldObjects()  #1

@mmtwr

Description

@mmtwr

Describe the bug
I am trying to use DisableAllFieldObjects() to disable all of the fields on a modeled form, Brief Addiction Monitor.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Brief Addiction Monitor'
  2. Click on 'Edit' with client 1717 in UAT
  3. See error preventing form loading:
    image

Expected behavior
I expect that on form load fields will be disabled. I want only the 'Category' field enabled.

Screenshots
In this image you can see the fields are beginning to appear disabled:
image
However, this image shows not all fields are getting disabled, specifically question 11:
image

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Browser Chrome (latest)
  • Version 83

Additional context
`using NLog;
using RarelySimple.AvatarScriptLink.Objects;
using Rosecrance.ScriptLinkService.Data.Models;
using Rosecrance.ScriptLinkService.Data.Repositories;
using System;
using System.Collections.Generic;
using System.Data.Odbc;

namespace Rosecrance.ScriptLinkService.Web.Commands
{
public class BAMFormLoadCommand : IRunScriptCommand
{
// ***********************************************************************************************
// Brief Addiction Monitor BAM FORM load
// -------------------------
// The form load function will disable all fields except the Category
// ***********************************************************************************************

    private static readonly Logger logger = LogManager.GetCurrentClassLogger();
    private readonly OptionObject2015 _optionObject2015;
    private readonly IGetDataRepository _repository;

    public BAMFormLoadCommand(OptionObject2015 optionObject2015, IGetDataRepository repository)
    {
        _optionObject2015 = optionObject2015;
        _repository = repository;
    }

    public OptionObject2015 Execute()
    {
        try
        {               
            string dateOfAssessmentFieldNumber = "263.89";
            string categoryFieldNumber = "264.13";
            string methodOfAdministration = "263.92";               
            
            logger.Debug("Method of Administration IsFieldEnabled before: " + _optionObject2015.IsFieldEnabled(methodOfAdministration));
            logger.Debug("Method of Administration IsFieldLocked before: " + _optionObject2015.IsFieldLocked(methodOfAdministration));

            _optionObject2015.SetEnabledField(categoryFieldNumber);
           
            List<string> fields = new List<string>();
            fields.Add(dateOfAssessmentFieldNumber);
            fields.Add("263.90");
            fields.Add(methodOfAdministration);
            fields.Add("263.93");
            fields.Add("263.94");
            fields.Add("263.95");
            fields.Add("263.96");
            fields.Add("263.97");
            fields.Add("263.98");
            fields.Add("263.99");
            fields.Add("264");
            fields.Add("264.01");
            fields.Add("264.02");
            fields.Add("264.03");
            fields.Add("264.04");
            fields.Add("264.05");
            fields.Add("264.06");
            fields.Add("264.07");
            fields.Add("264.08");
            fields.Add("264.09");
            fields.Add("264.10");
            fields.Add("264.11");
            //fields.Add("");
            //fields.Add("");
            _optionObject2015.SetDisabledFields(fields);
            _optionObject2015.DisableAllFieldObjects();
            //_optionObject2015.SetDisabledField("263.89");
            //_optionObject2015.SetDisabledField("263.90"); 
            //_optionObject2015.SetDisabledField(methodOfAdministration);                
        }

        catch (OdbcException ex)
        {
            logger.Error(ex, "An ODBC exception has occurred. See ODBC Data log for more detail.");
            return _optionObject2015.ToReturnOptionObject(ErrorCode.Error, "An ODBC exception has occurred. See the ODBC Data log on the web server for more detail.");
        }
        catch (Exception ex)
        {
            logger.Error(ex, "An unexpected error occurred. Error: {errorMessage}", ex.Message);
            return _optionObject2015.ToReturnOptionObject(ErrorCode.Error, "An unexpected error occurred. Please contact your system administrator. Error: " + ex.Message);
        }

        return _optionObject2015.ToReturnOptionObject();
    }
}

}`

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions