Aras Developer
Troubleshooting

Resolving 'Classification cannot be changed after saving the item' Error in Aras Innovator

Letisha Luimes
#Aras Innovator#.NET API#error handling#classification
Aras Innovator .NET API Error

Introduction

When working with Aras Innovator, developers often encounter the error message 'Classification cannot be changed after saving the item' when attempting to update a requirement using the .NET API. This error occurs even when the classification property is not being modified in the request. This blog post explains the root cause of this issue and provides a solution to resolve it effectively.

Root Cause

Aras Innovator enforces strict validation rules for certain item types, including requirements. One such rule is that the classification (type) of an item cannot be changed after it has been saved. The .NET API may trigger this validation error if the classification property is not explicitly handled in the update request, even if the property itself is not being modified.

Solution

To avoid this error, you must explicitly include the current classification value in your update request. This involves:

  1. Retrieving the current classification value from the item.
  2. Explicitly setting this value in the update request.

Below is a detailed example of how to implement this solution in your .NET API code.

Implementation

using System;
using System.Collections.Generic;
using Aras.IOM;

namespace TestArasProject
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            // Establish connection to Aras Innovator
            HttpServerConnection conn = IomFactory.CreateHttpServerConnection(serverUrl, dbName, username, password);
            Innovator inn = IomFactory.CreateInnovator(conn);
            conn.Login();

            // Retrieve the current item to get the classification
            Item getItem = inn.newItem("Requirement", "get");
            getItem.setAttribute("where", "[Requirement].config_id = '" + internalId + "' AND [Requirement].is_current='1'");
            Item currentItem = getItem.apply();
            string currentClassification = currentItem.getProperty("classification", "");

            // Create the update item with the current classification
            Item updateItem = inn.newItem("Requirement", "edit");
            string internalId = "FB20D91203DC4E3EB30DBA0CFBE4FD0F";
            updateItem.setAttribute("where", "[Requirement].config_id = '" + internalId + "' AND [Requirement].is_current='1'");
            
            // Set the classification from the retrieved value
            updateItem.setProperty("classification", currentClassification);
            
            // Update the requirement title
            updateItem.setProperty("req_rm_title", "Test Requirement " + Guid.NewGuid());

            // Apply the update
            Item result = updateItem.apply();

            // Output the result
            Console.WriteLine(result);
            Console.WriteLine(result.isError());
            Console.ReadLine();

            // Logout from Aras Innovator
            conn.Logout();
        }
    }
}

Steps

  1. Establish Connection: Use HttpServerConnection and Innovator classes to connect to Aras Innovator.
  2. Retrieve Current Item: Fetch the current requirement item to obtain its classification value.
  3. Prepare Update Request: Create an update request and explicitly set the classification property to the retrieved value.
  4. Apply Update: Execute the update request and handle the result.

Conclusion

By explicitly including the current classification value in your update request, you can avoid the 'Classification cannot be changed after saving the item' error in Aras Innovator. This approach ensures compliance with Aras Innovator’s validation rules and allows for seamless updates to requirement items using the .NET API. Implement this solution in your code to enhance the reliability and efficiency of your Aras Innovator integrations.