Discussion:
Need help in updating customer in CustTable
(too old to reply)
Sam
2009-03-20 05:54:00 UTC
Permalink
I am creating a customer via business connetor using the following code,

AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "Sampath");
axObj.Call("setName");
axObj.Call("parmNameAlias", "Sampath");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("save");
objAX.TTSCommit();

The above code works fine and customer is created in CustTable. But i have
tried to modify

the record using the following code;

AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "AX Test");
axObj.Call("setName");
axObj.Call("parmNameAlias", "AX Test");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("modify");
objAX.TTSCommit();

The above code doesnt update the customer entry with the modified details.

I dont know what i am missing here.

Could you please help me?

Thanks in Advance
Axel Kühn
2009-03-21 17:26:09 UTC
Permalink
Hi,

please try to also use the method "save" to update the record.

If you are working with AX<Table> classes (inherited from AXInternalBase),
you must call "save" if you will insert or update a record.
Please refer to the documentation about the AxInternalBase class:
http://msdn.microsoft.com/en-us/library/aa655764.aspx
http://msdn.microsoft.com/en-us/library/aa855122.aspx

Hope this helps you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Sam
I am creating a customer via business connetor using the following code,
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "Sampath");
axObj.Call("setName");
axObj.Call("parmNameAlias", "Sampath");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("save");
objAX.TTSCommit();
The above code works fine and customer is created in CustTable. But i have
tried to modify
the record using the following code;
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "AX Test");
axObj.Call("setName");
axObj.Call("parmNameAlias", "AX Test");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("modify");
objAX.TTSCommit();
The above code doesnt update the customer entry with the modified details.
I dont know what i am missing here.
Could you please help me?
Thanks in Advance
Sam
2009-03-28 10:28:01 UTC
Permalink
Thank you Axel. It works. Actually i am missing the following code.

Your reply triggering me to digg more on this issue. Thank you again.

Here is the missing code.

AxaptaRecord axRec = AX.CreateAxaptaRecord("CustTable");
axRec.ExecuteStmt("select forupdate * from %1 where %1.AccountNum=='1234'");
if (axRec.Found)
{
axObj.Call("currentrecord", axRec);
axObj.Call("save");
}

We need to assign the record to update.
-Sam
Post by Axel Kühn
Hi,
please try to also use the method "save" to update the record.
If you are working with AX<Table> classes (inherited from AXInternalBase),
you must call "save" if you will insert or update a record.
http://msdn.microsoft.com/en-us/library/aa655764.aspx
http://msdn.microsoft.com/en-us/library/aa855122.aspx
Hope this helps you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Sam
I am creating a customer via business connetor using the following code,
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "Sampath");
axObj.Call("setName");
axObj.Call("parmNameAlias", "Sampath");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("save");
objAX.TTSCommit();
The above code works fine and customer is created in CustTable. But i have
tried to modify
the record using the following code;
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "AX Test");
axObj.Call("setName");
axObj.Call("parmNameAlias", "AX Test");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("modify");
objAX.TTSCommit();
The above code doesnt update the customer entry with the modified details.
I dont know what i am missing here.
Could you please help me?
Thanks in Advance
Mubashir Ali
2011-09-25 23:10:31 UTC
Permalink
When I use CreateAxaptaObject method with save method I got following error. Please help me in updating record of custtable using CreateAxaptaObject

Error:

Cannot create a record in Customers (CustTable). Customer account: 9996, Mubashir.
The record already exists.

CODE:

Axapta objAX = new Axapta();
objAX.Logon("Bri", "", "", "");
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "9996");
axObj.Call("setAccountNum");
axObj.Call("parmName", "Mubashir");
axObj.Call("setName");
axObj.Call("parmNameAlias", "Mubashir");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "ACT");
axObj.Call("parmCountryRegionId", "AU");
axObj.Call("parmZipCode", "3004");
axObj.Call("parmCustGroup", "TEST");
objAX.TTSBegin();
axObj.Call("save");
objAX.TTSCommit();
Post by Sam
I am creating a customer via business connetor using the following code,
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "Sampath");
axObj.Call("setName");
axObj.Call("parmNameAlias", "Sampath");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("save");
objAX.TTSCommit();
The above code works fine and customer is created in CustTable. But i have
tried to modify
the record using the following code;
AxaptaObject axObj = objAX.CreateAxaptaObject("AxCustTable");
axObj.Call("parmAccountNum", "1234");
axObj.Call("setAccountNum");
axObj.Call("parmName", "AX Test");
axObj.Call("setName");
axObj.Call("parmNameAlias", "AX Test");
axObj.Call("setNameAlias");
axObj.Call("parmStreet", "abc123 street");
axObj.Call("parmCity", "Aberdeen");
axObj.Call("parmState", "MA");
axObj.Call("parmCountryRegionId", "US");
axObj.Call("parmZipCode", "01036");
axObj.Call("parmCustGroup", TEST");
objAX.TTSBegin();
objAX.call("modify");
objAX.TTSCommit();
The above code doesnt update the customer entry with the modified details.
I dont know what i am missing here.
Could you please help me?
Thanks in Advance
Post by Axel Kühn
Hi,
please try to also use the method "save" to update the record.
If you are working with AX<Table> classes (inherited from AXInternalBase),
you must call "save" if you will insert or update a record.
http://msdn.microsoft.com/en-us/library/aa655764.aspx
http://msdn.microsoft.com/en-us/library/aa855122.aspx
Hope this helps you.
--
Sincerely yours
Axel KÃŒhn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by Sam
Thank you Axel. It works. Actually i am missing the following code.
Your reply triggering me to digg more on this issue. Thank you again.
Here is the missing code.
AxaptaRecord axRec = AX.CreateAxaptaRecord("CustTable");
axRec.ExecuteStmt("select forupdate * from %1 where %1.AccountNum=='1234'");
if (axRec.Found)
{
axObj.Call("currentrecord", axRec);
axObj.Call("save");
}
We need to assign the record to update.
-Sam
Loading...