Stack Trace Error for RefTableId field assignment - axapta

I created a new table and added a new Integer field (called RefTableId) with an EDT of the standard RefTableId type. Writing NewTable.RefTableId = tableNum(SomeTable); compiles but during run time I get this stack trace error: "Error executing code: Wrong argument types in variable assignment."
I've even tried NewTable.RefTableId = 0; This still fails. And yes, I've triple checked that it is indeed an integer field.

The solution is really stupid, the line before the assignments was reading .data() out of a FormListItem object that had invalid data in it. Instead of showing an error for that line, it skips over it and fails the assignment lines below. It makes no sense to me since I wasn't using any information from that FormListItem object to populate any field data with, yet still caused that to fail for some reason. I'm going to mark this one in the "Bang Head Here" category.

If the code is in a class, be sure to do a compile of all super classes as well as a compile forward (child classes). Remember to do an incremental CIL.
If it still fails do a full compile (axbuild).

Related

How to locate the method using an error message string?

I would like to know where is this error code located in the AOT. Would like to know the path to understand the structure and develop custom code.
Transaction has been selected, for settlement, although settlement type: none was selected
I generally use one of two methods to locate message strings.
Provided the cross reference is updated (it should be in dev) use the "Label editor" to to search for then string, see this answer.
Put a breakpoint in top of info.add method, disable CIL if needed, then rerun to get the error message invoking the debugger, see this answer.

Two tables with different names and using the single record cannot be created, how can I implent this?

I'm trying to create two tables using the same record, with two different names, but it creates only any one of them or sometimes throws an exception.
Following is the code from my record file:
-record(account,{acctnum, cnic, name, address,date ,time, balance=0}).
Following is my code from module called accounts:
-module(accounts).
-compile(export_all).
-include("records.hrl").
start()->
ets:new(current,[named_table,{keypos, #account.cnic}]),
ets:new(savings,[named_table,{keypos, #account.cnic}]).
Sometimes it returns an atom called savings, but sometimes it gives the following error:
** exception error: bad argument
in function ets:new/2
called as ets:new(current,[named_table,{keypos,3}])
in call from accounts:start/0 (accounts.erl, line 5)
Please do let me know that either it's possible to create two tables in ets using a single record?
If not, then how can I Implement it, I'm trying to create two tables, one for the savings account and other for the current account, how can I resolve this problem?
There is not problem with creating two ETS based on one record.
** exception error: bad argument
in function ets:new/2
called as ets:new(current,[named_table,{keypos,3}])
in call from accounts:start/0 (accounts.erl, line 5)
Such exception usually means that the table with the same name is already created. I.e. function start was called twice (first one successfully, and second one - not).
When you execute start for the first time, everything is ok, and you get the result the last line of the function. You can check this by using the tv module; execute tv:start() and you can inspect any ets or mnesia table.
If you execute start again, then as Alexey says, you will get an error because the table current (and saving) already exists. This maks the shell crash, and destroy the 2 tables; so the next time you will use start, it will be ok again.
If you cannot know if the ets table is already existing, you can test it with a code like this:
ensure(T,Def) ->
case ets:info(T) of
undefined -> ets:new(T,Def);
_ -> ets:delete_all_objects(T) %% or anything you need to do in this case
end.

Symfony2 passed argument is null

I'm building a CRM system and I faced a weird problem I'm unable to solve. When I try to create a new CustomerCase entity, I want to assign a CaseState entity for it, so this is what I do in the createAction of CustomerCaseController.php:
$caseStateId = $request->request->get('caseState_id');
$caseState = $this->getDoctrine()->getManager()->getRepository('HSWAshaBundle:CaseState')->findOneById($caseStateId);
$entity = new CustomerCase();
$entity->setCaseState($caseState);
...... etc.....
Everything works just fine until the setCaseState method. After running setCaseState, I get the following error:
Catchable Fatal Error: Argument 1 passed to HSW\AshaBundle\Entity\CustomerCase::setCaseState() must be an instance of HSW\AshaBundle\Entity\CaseState, null given, called in /home/webuser/Symfony/vendor/symfony/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 538 and defined in /home/webuser/Symfony/src/HSW/AshaBundle/Entity/CustomerCase.php line 843
The weird part is that $caseState really is a CaseState object (because for example $caseState->getName() works and gives me the correct name for the selected CaseState). For some mind blowing reason it just turns null when I use the setCaseState method. If I do $entity->setCaseState($customerStateObject->getId()), I get the same error message, but this time null changes to integer.
The CustomerCase has a manyToOne relationship with CaseState.
This works just fine if I use the formBuilder's add() method and skip all this manual work, but since I'm using a very specific auto-populating jQuery dropdown for selecting the CaseState from a nested tree structure, I had to manually add the dropdown and read it with $request->request->get().
I've been fighting with this part for almost three days now and would greatly appreciate every help I can get with this!
Finally I got it to work! The reason was $request was missing some parameters because the twig template was missing form_rest(form). After adding that, everything started to work. Thank you!

Error while compiling botan sample example in Qt

I am trying to find out the error for two days but still haven't got this unknown reason figure out.
I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..
S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);
it says error: 'class Botan::PBKDF' has no member named 'set_iterations'
How can I solve this problem ?
The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.
According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.
First things first then, your code needs to be something more like:
PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");
Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.
Possibly you missed your library header... as your error message says: 'has no member named...'

"Failed to enable constraints" Error keeps cropping up (seemingly randomly) in my ASP.Net project

I have a weird problem where the "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." error sometimes pops up when I am trying to build my project.
The line in question throwing the error was auto-generated code in the designer file for the dataset. To find out the offending table, I used the following code:
Try
Me.Adapter.Fill(dataTable) <--Breakpoint here on the offending line
Catch ex As Exception
For Each TRow As DataRow In dataTable.Rows
If TRow.HasErrors Then
Trace.Write(TRow.RowError)
End If
Next
End Try
Funnily enough, as soon as I run the project after putting in the above code and breakpoint, the error disappears. I assume this has something to do with the code being regenerated. All data is presented successfully, and the project compiles without errors.
However, this has happened often enough for me to frustrate me. Anybody know what might be causing the error and how I can isolate it?
What unique constraint are you placing on the datatable and have you verified that the data your passing in doesn't have any duplicates? If this is coming from a shared database perhaps someone else is modifying the data which could be causing the randomness.
Edit
If that code is exactly as what you have (And forgive me my vb.net is not as strong as my C#). Wouldn't it swallow the exception? In C# we need to rethrow the error.
Add a Trace.Write() right before you go into your for loop.
You are probably working with a typed dataset, or have some code configuration on it. Also you might be reading from one table, and then adding data from another.
In any of those cases, you really want to look into any inconsistencies between the schema. If it is a typed dataset / or configured in code, check its definition, and look for anything different from the sql table. If you are reading from 2 different tables, check the definition of both tables.
Figured it out finally!
The reason the breakpoint wasn't being hit was because the code in question was auto-generated, and had the attribute "DebuggerNonUserCodeAttribute". In addition, in my VS settings, I had set the debugger to "Just my code".
When I ran the code again, and the breakpoint wasn't hit, I noticed the breakpoint icon had changed to a warning. Hovering showed this:
"The breakpoint will currently not be hit. Breakpoints cannot be set in a method or class with the 'DebuggerNonUserCode' attribute when the debugger option 'Just My Code' is enabled."
Ouch!
Once I had removed the "Just My Code" debugging option, the breakpoint was hit, and I discovered that one of the rows had a NULL value in one of the columns which had a non-null constraint. Stupid ole' me!
You should use this code before you fill DataTable :
var dt = new System.DataTable.DataTable();
dt.Clear();
dt.Rows.Clear();
dt.Columns.Clear();

Resources