locked
Error: 400007:The operation is not valid for the condition or action.:BusinessRuleItem RRS feed

  • Question

  • Hi,

    I am new to MDS and MDS API. I am trying to create a business rule using MDS API and my code is as below. Please let me know where I am making mistake. I am getting an error saying "Error: 400007:The operation is not valid for the condition or action.:BusinessRuleItem".

    public static void CreateBusinessRuleForStudy()
        {
          CommonFunctions.LogInfo("Entered method CreateBusinessRuleForStudy()");
          mdsProxy = mdsProxy = CreateServiceProxy(Constants.serviceUrl);
          BusinessRulesCreateRequest request = new BusinessRulesCreateRequest();
          BusinessRulesCreateResponse response = new BusinessRulesCreateResponse();
    
          request.BusinessRuleSet = new BusinessRules()
          {
            BusinessRulesMember = new Collection<BusinessRule>()
            {
              new BusinessRule()
              {
                Identifier = new MemberTypeContextIdentifier
                {
                  ModelId = new Identifier { Name = "Test" },
                  EntityId = new Identifier { Name = "Study"},
                  Name = "NewBusinessRuleOne",
                  MemberType = MemberType.Leaf
                },
                BRConditionTree = new BRConditionTreeNode
                {
                  Identifier = new Identifier 
                  {
                    Name = "BusinessRuleConditionTreeOne",
                  },
                  BRConditions = new Collection<BRCondition>()
                  {
                    new BRCondition()
                    {
                      Identifier = new Identifier
                      {
                        Name = "BRContionIsEqualTo",
                      },
                      Sequence = 1,
                      Operator = BRItemType.EqualsValue,
                      PrefixArgument = new BRAttributeArgument() 
                      { 
                        AttributeId = new Identifier 
                        { 
                          Name = "StudyTitle" 
                        }, 
                        PropertyName = BRPropertyName.Anchor
                      },
                      PostfixArguments = new Collection<object>()
                      {
                        new BRFreeformArgument() 
                        {
                          PropertyName = BRPropertyName.Value,
                          Value = "Feasibility of MDS"
                        }
                      }
                    }
                  },
                  Sequence = 1,
                  LogicalOperator = LogicalOperator.NotSpecified,
                },
                Priority = 1,
                //BRActions = new Collection<BRAction>()
                //{
                //  new BRAction()
                //  {
                //    Identifier = new Identifier { Name="SendEmail" },
                //    Sequence = 1
                //  }
                //}
              }
            }
          };
    
          response = mdsProxy.BusinessRulesCreate(request);
          HandleErrors(response.OperationResult);
          mdsProxy = null;
          CommonFunctions.LogInfo("Exited method CreateBusinessRuleForStudy()");
        }
    

    Thanks,

    Himanshu.

     


    Thanks, Himanshu.
    Sunday, January 23, 2011 1:57 PM

Answers

  • Hi All,

     

    The issue is resolved. I took incorrect PropertyName as BRPropertyName.Anchor. It should have been BRPropertyName.Value. Below is the working code.

    Thanks for helping out Xavier.

     public static void CreateBusinessRuleForStudy(Study obj)
        {
          CommonFunctions.LogInfo("Entered method CreateBusinessRuleForStudy()");
          mdsProxy = mdsProxy = CreateServiceProxy(Constants.serviceUrl);
          BusinessRulesCreateRequest request = new BusinessRulesCreateRequest();
          BusinessRulesCreateResponse response = new BusinessRulesCreateResponse();
    
          request.BusinessRuleSet = new BusinessRules
          {
            BusinessRulesMember = new Collection<BusinessRule>
            {
              new BusinessRule
              {
                Identifier = new MemberTypeContextIdentifier
                {
                  ModelId = new Identifier { Name = "Test" },
                  EntityId = new Identifier { Name = "Study"},
                  Name = "NewBusinessRuleOne",
                  MemberType = MemberType.Leaf
                },
                BRConditionTree = new BRConditionTreeNode
                {
                  Identifier = new Identifier 
                  {
                    Name = "BusinessRuleConditionTreeOne",
                  },
                  BRConditions = new Collection<BRCondition>
                  {
                    new BRCondition
                    {
                      Identifier = new Identifier
                      {
                        Name = "BRContionIsEqualTo",
                      },
                      Sequence = 1,
                      Operator = BRItemType.IsEqual,
                      PrefixArgument = new BRAttributeArgument
                      { 
                        AttributeId = new Identifier 
                        { 
                          Name = "StudyTitle" 
                        }, 
                        PropertyName = BRPropertyName.Value
                      },
                      PostfixArguments = new Collection<Object>
                      {
                        new BRFreeformArgument
                        {
                          PropertyName = BRPropertyName.Value,
                          Value = "ABC"
                        }
                      }
                    }
                  },
                  Sequence = 1,
                  LogicalOperator = LogicalOperator.NotSpecified,
                },
                Priority = 1,
                BRActions = new Collection<BRAction>
                {
                  new BRAction
                  {
                    Identifier = new Identifier { Name="IsNotValid" },
                    Sequence = 1,
                    Operator = BRItemType.Invalid,
                    PrefixArgument = new BRAttributeArgument
                    {
                      AttributeId = new Identifier { Name = "StudyTitle"},
                      PropertyName = BRPropertyName.Value
                    },
                  }
                }
              }
            }
          };
    
          response = mdsProxy.BusinessRulesCreate(request);
          HandleErrors(response.OperationResult);
          mdsProxy = null;
          CommonFunctions.LogInfo("Exited method CreateBusinessRuleForStudy()");
        }
    


    Thanks, Himanshu.
    • Proposed as answer by shalhim Monday, January 24, 2011 9:22 AM
    • Marked as answer by Himanshu Saxena Monday, January 24, 2011 9:40 AM
    Monday, January 24, 2011 9:21 AM

All replies

  • Hi,

    I am new to MDS and MDS API. I am trying to create a business rule using MDS API and my code is as below. Please let me know where I am making mistake. I am getting an error saying "Error: 400007:The operation is not valid for the condition or action.:BusinessRuleItem".

     

    public static void CreateBusinessRuleForStudy()
      {
       CommonFunctions.LogInfo("Entered method CreateBusinessRuleForStudy()");
       mdsProxy = mdsProxy = CreateServiceProxy(Constants.serviceUrl);
       BusinessRulesCreateRequest request = new BusinessRulesCreateRequest();
       BusinessRulesCreateResponse response = new BusinessRulesCreateResponse();
    
       request.BusinessRuleSet = new BusinessRules()
       {
        BusinessRulesMember = new Collection<BusinessRule>()
        {
         new BusinessRule()
         {
          Identifier = new MemberTypeContextIdentifier
          {
           ModelId = new Identifier { Name = "Test" },
           EntityId = new Identifier { Name = "Study"},
           Name = "NewBusinessRuleOne",
           MemberType = MemberType.Leaf
          },
          BRConditionTree = new BRConditionTreeNode
          {
           Identifier = new Identifier 
           {
            Name = "BusinessRuleConditionTreeOne",
           },
           BRConditions = new Collection<BRCondition>()
           {
            new BRCondition()
            {
             Identifier = new Identifier
             {
              Name = "BRContionIsEqualTo",
             },
             Sequence = 1,
             Operator = BRItemType.EqualsValue,
             PrefixArgument = new BRAttributeArgument() 
             { 
              AttributeId = new Identifier 
              { 
               Name = "StudyTitle" 
              }, 
              PropertyName = BRPropertyName.Anchor
             },
             PostfixArguments = new Collection<object>()
             {
              new BRFreeformArgument() 
              {
               PropertyName = BRPropertyName.Value,
               Value = "Feasibility of MDS"
              }
             }
            }
           },
           Sequence = 1,
           LogicalOperator = LogicalOperator.NotSpecified,
          },
          Priority = 1,
          //BRActions = new Collection<BRAction>()
          //{
          // new BRAction()
          // {
          //  Identifier = new Identifier { Name="SendEmail" },
          //  Sequence = 1
          // }
          //}
         }
        }
       };
    
       response = mdsProxy.BusinessRulesCreate(request);
       HandleErrors(response.OperationResult);
       mdsProxy = null;
       CommonFunctions.LogInfo("Exited method CreateBusinessRuleForStudy()");
      }
    

     

    Thanks,

    Himanshu.

     


    Thanks, Himanshu.

    I am trying to create a simple business rule that compares the value of an attribute with a string value supplied. As I read the API on MSDN I am assuming that PrefixArgument is left side of equation and PostArgument is the right side. So for PrefixArgument I have specified the value to be the attribute itself and for PostFixArgument I am passing a string value. Please let me know I am mistaked.

    Thanks,

    Himanshu.

     


    Thanks, Himanshu.
    Sunday, January 23, 2011 2:09 PM
  • Hi,

    I am new to MDS and MDS API. I am trying to create a business rule using MDS API and my code is as below. Please let me know where I am making mistake. I am getting an error saying "Error: 400007:The operation is not valid for the condition or action.:BusinessRuleItem".

     

    public static void CreateBusinessRuleForStudy()
     {
      CommonFunctions.LogInfo("Entered method CreateBusinessRuleForStudy()");
      mdsProxy = mdsProxy = CreateServiceProxy(Constants.serviceUrl);
      BusinessRulesCreateRequest request = new BusinessRulesCreateRequest();
      BusinessRulesCreateResponse response = new BusinessRulesCreateResponse();
    
      request.BusinessRuleSet = new BusinessRules()
      {
      BusinessRulesMember = new Collection<BusinessRule>()
      {
       new BusinessRule()
       {
       Identifier = new MemberTypeContextIdentifier
       {
        ModelId = new Identifier { Name = "Test" },
        EntityId = new Identifier { Name = "Study"},
        Name = "NewBusinessRuleOne",
        MemberType = MemberType.Leaf
       },
       BRConditionTree = new BRConditionTreeNode
       {
        Identifier = new Identifier 
        {
        Name = "BusinessRuleConditionTreeOne",
        },
        BRConditions = new Collection<BRCondition>()
        {
        new BRCondition()
        {
         Identifier = new Identifier
         {
         Name = "BRContionIsEqualTo",
         },
         Sequence = 1,
         Operator = BRItemType.EqualsValue,
         PrefixArgument = new BRAttributeArgument() 
         { 
         AttributeId = new Identifier 
         { 
          Name = "StudyTitle" 
         }, 
         PropertyName = BRPropertyName.Anchor
         },
         PostfixArguments = new Collection<object>()
         {
         new BRFreeformArgument() 
         {
          PropertyName = BRPropertyName.Value,
          Value = "Feasibility of MDS"
         }
         }
        }
        },
        Sequence = 1,
        LogicalOperator = LogicalOperator.NotSpecified,
       },
       Priority = 1,
       //BRActions = new Collection<BRAction>()
       //{
       // new BRAction()
       // {
       // Identifier = new Identifier { Name="SendEmail" },
       // Sequence = 1
       // }
       //}
       }
      }
      };
    
      response = mdsProxy.BusinessRulesCreate(request);
      HandleErrors(response.OperationResult);
      mdsProxy = null;
      CommonFunctions.LogInfo("Exited method CreateBusinessRuleForStudy()");
     }
    

     

    Thanks,

    Himanshu.

     


    Thanks, Himanshu.

    I am trying to create a simple business rule that compares the value of an attribute with a string value supplied. As I read the API on MSDN I am assuming that PrefixArgument is left side of equation and PostArgument is the right side. So for PrefixArgument I have specified the value to be the attribute itself and for PostFixArgument I am passing a string value. Please let me know I am mistaked.

    Thanks,

    Himanshu.

     


    Thanks, Himanshu.

    Hi All,

    Can anyone please share an example of how to create a simple business rule using MDS API, or please point to any reference material?


    Thanks, Himanshu.
    Monday, January 24, 2011 6:29 AM
  • Hi Himanshu,

     

    you can check this thread that contains a example:

    http://social.msdn.microsoft.com/Forums/en-US/sqlmds/thread/efcc6179-b3e0-472a-a27c-2097871435b2

     

     


    Note: Please vote/mark the post as answered if it answers your question/helps to solve your problem. _________________________________________________________ Regards, Xavier Averbouch, Consultant, Avanade France
    Monday, January 24, 2011 6:31 AM
  • Hi All,

     

    The issue is resolved. I took incorrect PropertyName as BRPropertyName.Anchor. It should have been BRPropertyName.Value. Below is the working code.

    Thanks for helping out Xavier.

     public static void CreateBusinessRuleForStudy(Study obj)
        {
          CommonFunctions.LogInfo("Entered method CreateBusinessRuleForStudy()");
          mdsProxy = mdsProxy = CreateServiceProxy(Constants.serviceUrl);
          BusinessRulesCreateRequest request = new BusinessRulesCreateRequest();
          BusinessRulesCreateResponse response = new BusinessRulesCreateResponse();
    
          request.BusinessRuleSet = new BusinessRules
          {
            BusinessRulesMember = new Collection<BusinessRule>
            {
              new BusinessRule
              {
                Identifier = new MemberTypeContextIdentifier
                {
                  ModelId = new Identifier { Name = "Test" },
                  EntityId = new Identifier { Name = "Study"},
                  Name = "NewBusinessRuleOne",
                  MemberType = MemberType.Leaf
                },
                BRConditionTree = new BRConditionTreeNode
                {
                  Identifier = new Identifier 
                  {
                    Name = "BusinessRuleConditionTreeOne",
                  },
                  BRConditions = new Collection<BRCondition>
                  {
                    new BRCondition
                    {
                      Identifier = new Identifier
                      {
                        Name = "BRContionIsEqualTo",
                      },
                      Sequence = 1,
                      Operator = BRItemType.IsEqual,
                      PrefixArgument = new BRAttributeArgument
                      { 
                        AttributeId = new Identifier 
                        { 
                          Name = "StudyTitle" 
                        }, 
                        PropertyName = BRPropertyName.Value
                      },
                      PostfixArguments = new Collection<Object>
                      {
                        new BRFreeformArgument
                        {
                          PropertyName = BRPropertyName.Value,
                          Value = "ABC"
                        }
                      }
                    }
                  },
                  Sequence = 1,
                  LogicalOperator = LogicalOperator.NotSpecified,
                },
                Priority = 1,
                BRActions = new Collection<BRAction>
                {
                  new BRAction
                  {
                    Identifier = new Identifier { Name="IsNotValid" },
                    Sequence = 1,
                    Operator = BRItemType.Invalid,
                    PrefixArgument = new BRAttributeArgument
                    {
                      AttributeId = new Identifier { Name = "StudyTitle"},
                      PropertyName = BRPropertyName.Value
                    },
                  }
                }
              }
            }
          };
    
          response = mdsProxy.BusinessRulesCreate(request);
          HandleErrors(response.OperationResult);
          mdsProxy = null;
          CommonFunctions.LogInfo("Exited method CreateBusinessRuleForStudy()");
        }
    


    Thanks, Himanshu.
    • Proposed as answer by shalhim Monday, January 24, 2011 9:22 AM
    • Marked as answer by Himanshu Saxena Monday, January 24, 2011 9:40 AM
    Monday, January 24, 2011 9:21 AM