The Records is not in editable state

SOLVED

Hi,

I got this "The Records is not in editable state" Error while delete contact from Ar_CustomerContact_bus object. 

Please anyone give hint to solve this issue.

Thanks.

  • 0
    verified answer
    Hint: summit's wrong in your code.
  • 0 in reply to 49153
    Hi,

    Here is the code.



    object pvx = null;
    object oSS = null;
    CreateLogFiles Err = new CreateLogFiles();
    // Instantiate a ProvidexX.Script object and initialize with the path to MAS90\Home
    pvx = System.Activator.CreateInstance(Type.GetTypeFromProgID("ProvideX.Script", true));
    // Replace the text "*PATH TO MAS90\HOME*" with the correct MAS90\Home path in the line below
    pvx.GetType().InvokeMember("Init", BindingFlags.InvokeMethod, null, pvx, new object[] { ConfigurationManager.AppSettings["SagePath"].ToString() });



    // Instantiate a new Session object and initialize the session
    // by setting the user, company, date and module
    oSS = pvx.GetType().InvokeMember("NewObject", BindingFlags.InvokeMethod, null, pvx, new object[] { "SY_Session" });




    oSS.GetType().InvokeMember("nSetCompany", BindingFlags.InvokeMethod, null, oSS, new object[] { ConfigurationManager.AppSettings["CompanyName"].ToString() });

    oSS.GetType().InvokeMember("nSetDate", BindingFlags.InvokeMethod, null, oSS, new object[] { "A/R", "07252016" });

    oSS.GetType().InvokeMember("nSetModule", BindingFlags.InvokeMethod, null, oSS, new object[] { "A/R" });

    oSS.GetType().InvokeMember("nSetUser", BindingFlags.InvokeMethod, null, oSS, new object[] { "user", "password" });

    oSS.GetType().InvokeMember("nLogon", System.Reflection.BindingFlags.InvokeMethod, null, oSS, null);



    int TaskID = (int)oSS.GetType().InvokeMember("nLookupTask", System.Reflection.BindingFlags.InvokeMethod, null, oSS, new object[] { "AR_CustomerContact_ui" });

    oSS.GetType().InvokeMember("nSetProgram", System.Reflection.BindingFlags.InvokeMethod, null, oSS, null);


    m_object = pvx.GetType().InvokeMember("NewObject", BindingFlags.InvokeMethod, null, pvx, new object[] { "AR_CustomerContact_bus", oSS });



    object retVal = 0;

    retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "ARDivisionNo$", ConfigurationManager.AppSettings["ARDivisionNo"] });
    retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "CustomerNo$", ConfigurationManager.AppSettings["CustomerNo"] });
    retVal = oARCustomerEntry.InvokeMethodByRef("nSetKeyValue", new object[] { "ContactCode$", ConfigurationManager.AppSettings["ContactCode"] });



    retVal = oARCustomerEntry.InvokeMethod("nDelete");
    Err.ErrorLog(".//", "Execute Delete");

    if (retVal.ToString() == "0")
    {
    object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
    Console.WriteLine(errorMsg.ToString());
    Err.ErrorLog(".//", errorMsg.ToString());
    Console.Read();
    }

    // string customerNumber = nextCustomerNumber[0].ToString();

    Console.WriteLine(retVal.ToString());

    Console.Read();
    }
    catch (Exception ex)
    {
    object errorMsg = oARCustomerEntry.GetProperty("sLastErrorMsg");
    Err.ErrorLog(".//", errorMsg.ToString());
    Console.WriteLine(errorMsg.ToString());
    Console.WriteLine(ex.Message);
    Console.Read();
    }






    thanks
  • 0 in reply to sf_developer
    If you are using SetKeyValue to set each individual field that comprises the key to the table, you must then execute the SetKey method to put the record into an editable state.
  • 0 in reply to Steve Passmore
    Thanks Steve,

    It's resolve my error, But still it's not delete the records, can you please tell me from where I can get that what parameter need to pass for the delete a record? I mean key parameter ?

    Here is the code

    string par = ConfigurationManager.AppSettings["ARDivisionNo"] + "-" + ConfigurationManager.AppSettings["CustomerNo"] + ConfigurationManager.AppSettings["ContactCode"];

    retVal = oARCustomerEntry.InvokeMethod("nDelete", par);

    It's return the 1, But it is not delete the record.

    Please help me, give me some hint or some reference document where I can check the key parameter.

    Thanks,
  • 0 in reply to sf_developer
    verified answer
    When you have a record loaded in the business object as you do, simply invoking the Delete method with no argument should work. I tried doing a delete with the business object as you are doing and it worked for me.

    The Delete method also will accept an argument of the specific key to delete. With the multi-part key of AR_CustomerContact it would require you to pad out each key segment to the defined length of the field, concatenating the three fields into a single string value to use as that argument. For multi-part key tables it is easier to do what you are doing.

    If the Delete method is returning success but the record is still in the table, I'm at a loss to explain that...
  • 0 in reply to Steve Passmore
    Hi Steve,

    Thanks for the reply, I tried all the way but it not solved my issue. Can you please share with me the sample running code which you did?

    It's so urgent, Please help me

    Thanks
  • 0 in reply to sf_developer
    The only thing I can think of for you to check is the return value of the SetKey() method. If the value being returned is a 2 that would indicate there is a problem with setting the key of the record you want to delete. A return value of 2 means the record is new. In your scenario you want a return value of 1 which would mean an existing record was found.
  • 0 in reply to Steve Passmore
    And if SetKey() method return 0 then?
  • 0 in reply to sf_developer
    Zero (0) indicates a failure. Check the LastErrorMsg$ property to get information about the error that is occurring.
  • 0 in reply to Steve Passmore
    Hi Steve,

    Thank you very very much...for helping me, I got success in delete the record.