"Classification cannot be changed after saving the item" error using the .Net API to update requirement

I am using Aras 11 SP15. I am trying to update a requirement I created. Here is my code:

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

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

            Item updateItem = inn.newItem(requirement, "edit");
            string internalId = "FB20D91203DC4E3EB30DBA0CFBE4FD0F";
            updateItem.setAttribute("where", "[" + requirement.Replace(' ', '_') + "]." + "config_id" + " = '" + internalId + "' AND [" + requirement.Replace(' ', '_') + "]." + "is_current" + "='1'");

            // updating the name of the requirement
            updateItem.setProperty("req_rm_title", "Test Requirement" + Guid.NewGuid());

            Item result = updateItem.apply();

            Console.WriteLine(result);
            Console.WriteLine(result.isError());
            Console.ReadLine();

            conn.Logout();
       }

    }
}

I am getting the following error:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../" xmlns:i18n="">www.aras.com/I18N"><SOAP-ENV:Body><SOAP-ENV:Fault>
<faultcode>1</faultcode>
<faultactor />
<faultstring>Classification cannot be changed after saving the item.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

I checked the XML which was getting created to update, this XML did not even contain the Classification property nor am I trying to update it. Here is the XML: 

<Item isNew=\"1\" isTemp=\"1\" type=\"re_Requirement\" action=\"edit\" where=\"[re_Requirement].config_id = '3AFD850B785E43F1B854EE404469FA87' AND [re_Requirement].is_current='1'\">
    <req_title>2019_06_24_12_25_42_850_-{AB}</req_title>
</Item>

I noticed that Classification (Type) is a default value on UI still I need to explicitly pass it through the API. This is not the case with Risk or Complexity type of fields. How do I update a requirement?

Parents
  • Hi archan,

    This is similar behavior to what you previously reported when adding a new requirement through AML. The onBeforeUpdate server event on the re_Requirement ItemType expects that the classification property will be specified in the AML since that's how the AML is formatted when an update is submitted through the Aras Innovator client. You can resolve this issue by adding the classification property to your request and doing per-classification updates in your code. 

    This is known behavior in RE 11.0R1 that will be addressed in a future release. 

    Chris

  • Hi Christopher,

    I tried to add the classification as well with the same value I had provided during the time of creation. Now I am getting a different error:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
        <SOAP-ENV:Body>
            <SOAP-ENV:Fault xmlns:af="">www.aras.com/InnovatorFault">
                <faultcode>SOAP-ENV:Server</faultcode>
                <faultstring><![CDATA[No items of type re_Requirement found.]]></faultstring>
                <detail>
                    <af:legacy_detail><![CDATA[No items of type re_Requirement found.]]></af:legacy_detail>
                    <af:exception message="No items of type re_Requirement found." type="System.Exception" />
                </detail>
            </SOAP-ENV:Fault>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

  • Hi archan,

    Have you updated the where clause in your AML to include a check for the classification like "... and [re_Requirement].classification = 'Text'  ..."

    Chris

Reply Children
  • Hi Christopher,

    Yes I tried that. I was adding it in the body first. Now I tried to add it in the where clause, and I am getting that error again which I was getting in the first place.

    Here is my AML DOM, just trying a simple update by changing the requirement title by appending GUID to it

    <Item isNew="1" isTemp="1" type="re_Requirement" action="edit" where="[re_Requirement].config_id = '68A75D9AAD4346E9A067B8A83C268657' AND [re_Requirement].is_current='1' AND [re_Requirement].classification = 'Requirement'">
        <req_title>Test Requirement6247822e-20f9-4f7c-aa60-424360271702</req_title>
    </Item>

    The same error:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../" xmlns:i18n="">http://www.aras.com/I18N">
        <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>1</faultcode>
            <faultactor />
            <faultstring>Classification cannot be changed after saving the item.</faultstring>
        </SOAP-ENV:Fault>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

  • Hello,

    I believe to work around this issue you'll need to include the requirement in both the where clause as well as the body.

    <Item isNew="1" isTemp="1" type="re_Requirement" action="edit" where="[re_Requirement].config_id = '68A75D9AAD4346E9A067B8A83C268657' AND [re_Requirement].is_current='1' AND [re_Requirement].classification = 'Requirement'">
        <req_title>Test Requirement6247822e-20f9-4f7c-aa60-424360271702</req_title>
        <classification>Requirement</classification>
    </Item>

    Any properties in the body of an edit or update will be applied as changes to any items that satisfy the where condition specified in the attribute. Because of the inability to change the classification of the requirements, you'll need to run this update once per-classification by specifying the classification in both the where clause and the body.

    Chris

  • Hello Christopher,

    Apologies for the delayed reply. Unfortunately, including classification in where clause and body did not work. Now I am getting this error again:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
        <SOAP-ENV:Body>
            <SOAP-ENV:Fault xmlns:af="">www.aras.com/InnovatorFault">
                <faultcode>SOAP-ENV:Server</faultcode>
                <faultstring><![CDATA[No items of type re_Requirement found.]]></faultstring>
                <detail>
                    <af:legacy_detail><![CDATA[No items of type re_Requirement found.]]></af:legacy_detail>
                    <af:exception message="No items of type re_Requirement found." type="System.Exception" />
                </detail>
            </SOAP-ENV:Fault>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    This is the AML being created:

    <Item isNew=\"1\" isTemp=\"1\" type=\"re_Requirement\" action=\"edit\" where=\"[re_Requirement].config_id = 'D4C1DBC53A464A179043F3EC01BBEAB1' AND [re_Requirement].is_current='1' AND [re_Requirement].classification = 'Test'\">
        <req_title>Test Requirementff341cb6-cb81-4425-a144-067e3b973310</req_title>
        <classification>Test</classification>
    </Item>

    I am stuck now. Please suggest any other solution or something else I can do to update Requirement using the API. Is the same error being reproduced at your end as well ?

  • Could you test that the where clause is getting the item to edit? You can do this by removing the body and changing the action from edit to get

  • Hi Christopher,

    Yes, the item is being returned by changing the action to get. I am getting the proper result.

  • I took a look at the onBeforeUpdate event of the re_Requirement and it looks like it's trying to a get from the database based on the config_id property of the requirement. Because your AML does not have a config_id, this get is likely what's throwing the error you're seeing.

    I'd recommend checking the server events for the re_Requirement ItemType if you continue to run into issues like this. It seems there are a number of expected properties that need to be included in your queries.

    Chris

  • I took a look at the list of Methods I have and it is showing only onBeforeUpdateVariable method. Am i looking at the right place? Can you please tell me how can I see that method's logic ?

  • 0 オフライン in reply to archan96

    If you have exact ID, then in the where class, no need to add additional conditions.

    Ex: updateItem.setID(internalId);

    And you can edit the Item, by disabling servers events(Note: It will not execute any server methods, so all the conditions which are there in server methods will not execute)


    updateItem.setAttribute("serverEvents", "0");

  • 0 オフライン in reply to Nara

    Using this I was able to update the Requirement only once. It did not work the second time. Even if there is some workaround for this, is this a good practice to update an Item by disabling the server events ?

  • 0 オフライン in reply to archan96

    It's depends on your requirement, if you are doing Data Migration to load the data, then we will disable "serverEvents" while loading the data.

    If you are calling above code in server method, then we shouldn't disable "serverEvents".

    It should work 2nd time also. what is the error message your getting 2nd time?