The code below is what I am using for my invoices to be Posted
ledgerJournalTable = header.ledgerJournalTable();
if (ledgerJournalTable.RecId > 0)
{
ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes, NoYes::Yes);
// Post only if there is succesful validation.
if (ledgerJournalCheckPost.validate())
{
ledgerJournalCheckPost.run();
}
else
{
info("Error.");
}
}
but there is always an error that says:
"Journal does not exist"
All the values that I've placed on the fields are correct because when I tried to use the same values manually, it was posted.
What could be wrong when that error pops up?
Edit1: As I've used breakpoint, I found out that in LedgerJournalCheckPost.validate() the ledgerJournalTable.JournalNum is empty "".
Found out that the ledgerJournalCheckPost.run() already has/calls the validate() method inside it, so there's no need to call the validate() method. However, I still don't know how to solve if you're going to use the validate() method through x++o code.
Related
Take any sales order with a line that has fields SalesLine.Name and SalesLine.ExternalItemId populated.
Then run following job trying to modify any field not related to the two above:
SalesLine sl = SalesLine::findInventTransId('US01-000025', true);
ttsBegin;
sl.CustomerLineNum = 100; //any other field will serve as well
sl.modifiedField(fieldNum(SalesLine, CustomerLineNum)); //causes the issue
sl.update();
ttsCommit;
When the job has completed, both Name and ExternalItemId will be reset.
The issue is caused by line this.axInventDim().isFieldSet(fieldNum(InventDim, ConfigId)) in \Classes\AxSalesLine\isCustExternalItemDescriptionFieldsSet, which always returns true.
As a result, methods AxSalesLine.setName and AxSalesLine.setExternalItemId populate respective fields with default values.
Any advice on the reason it has been coded in Microsoft this way, and the best way to fix this?
P.S. I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId that was introduced in R2 CU7
This is a base bug that was resolved 4/30/15 on KB3061573.
https://fix.lcs.dynamics.com/Issue/Resolved?kb=3061573&bugId=3612128&qc=83c15cd8881ece605195acc30e039142
I think the full method fix is close to what you have, but the hotfix may also adjust other methods. I hope this hotfix is satisfying knowing you're not crazy.
protected void setRetailVariantId()
{
InventDimCombination comb;
InventDim inventDim;
;
comb = InventDimCombination::findVariantId(salesLine.RetailVariantId);
inventDim = this.axInventDim().inventDim();
if(comb)
{
if (inventDim.InventSizeId != comb.inventDim().InventSizeId)
{
this.axInventDim().parmInventSizeId(comb.inventDim().InventSizeId);
}
if (inventDim.InventColorId != comb.inventDim().InventColorId)
{
this.axInventDim().parmInventColorId(comb.inventDim().InventColorId);
}
if (inventDim.InventStyleId != comb.inventDim().InventStyleId)
{
this.axInventDim().parmInventStyleId(comb.inventDim().InventStyleId);
}
if (inventDim.configId != comb.inventDim().configId)
{
this.axInventDim().parmConfigId(comb.inventDim().configId);
}
}
}
// </RETAIL>
As I mentioned in the postscript, I narrowed down the issue to method \Classes\AxSalesLine\setRetailVariantId, which was introduced in R2 CU7.
As a workaround, I have added one line to the code, it resolved the issue:
if (this.axInventDim().parmConfigId() != comb.inventDim().configId) // added check
this.axInventDim().parmConfigId(comb.inventDim().configId);
I'll wait some time for a better answer/fix. If none provided, I will accept this answer.
I just started using Razor instead of the WebForms-ViewEngine. Now in my Razor-View i have something like this:
#{
int i = 42;
string text;
if (i == 42)
{
text = "i is 42!";
}
else //i is not 42 //<- Error here
{
text = "i is something else";
}
}
I get a warning and at runtime it get an exception in the else line:
Expected a "{" but found a "/". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages.
Apparently the compiler doesn't like comments between the else and the {. I also tried commenting with #* and /*, which gave similar error-messages.
Is there anyway to make a comment in razor like I want it?
Disclaimer:
Yes i know i could fix it simply like this:
#{
int i = 42;
string text;
if (i == 42)
{
text = "i is 42!";
}
else
{ //i is not 42
text = "i is something else";
}
}
However it doesn't fit our coding guidelines and having the comment on the same line makes my intentions more clear.
That's how the Razor parser is built. You could always submit a bug/feature request on MS connect if you don't like the way it is and hope that people will vote for it and it will be fixed/implemented in a future version of the parser. Personally I wouldn't because I don't care (see below why).
This being said, why care? I mean you are not supposed to write code in a Razor page. A Razor page is intended to be used as a view. In ASP.NET MVC a view is used to display some information from the view model that is passed to it from the controller action. Markup primary, mixed with HTML helpers and displaying information from the view model. But C# code is a no no. So what you call code and what you have shown in your question has strictly nothing to do in a Razor view.
I'm currently trying to implement an automated bug reporter for a Flex application, and would like to return error messages to a server along with the function/line number that caused the error. Essentially, I'm trying to get the getStackTrace() information without going into debug mode, because most users of the app aren't likely to have the debug version of flash player.
My current method is using the UncaughtErrorEvent handler to catch errors that occur within the app, but the error message only returns the type of error that has occurred, and not the location (which means it's useless). I have tried implementing getStackTrace() myself using a function name-grabber such as
private function getFunctionName (callee:Function, parent:Object):String {
for each ( var m:XML in describeType(parent)..method) {
if ( this[m.#name] == callee) return m.#name;
}
return "private function!";
}
but that will only work because of arguments.callee, and so won't go through multiple levels of function calls (it would never get above my error event listener).
So! Anyone have any ideas on how to get informative error messages through the global
error event handler?
EDIT: There seems to be some misunderstanding. I'm explicitly avoiding getStackTrace() because it returns 'null' when not in debug mode. Any solution that uses this function is what I'm specifically trying to avoid.
Just noticed the part about "I don't want to use debug." Well, that's not an option, as the non-debug version of Flash does not have any concept of a stack trace at all. Sucks, don't it?
Not relevant but still cool.
The rest is just for with the debug player.
This is part of my personal debug class (strangely enough, it is added to every single project I work on). It returns a String which represents the index in the stack passed -- class and method name. Once you have those, line number is trivial.
/**
* Returns the function name of whatever called this function (and whatever called that)...
*/
public static function getCaller( index:int = 0 ):String
{
try
{
throw new Error('pass');
}
catch (e:Error)
{
var arr:Array = String(e.getStackTrace()).split("\t");
var value:String = arr[3 + index];
// This pattern matches a standard function.
var re:RegExp = /^at (.*?)\/(.*?)\(\)/ ;
var owner:Array = re.exec(value);
try
{
var cref:Array = owner[1].split('::');
return cref[ 1 ] + "." + owner[2];
}
catch( e:Error )
{
try
{
re = /^at (.*?)\(\)/; // constructor.
owner = re.exec(value);
var tmp:Array = owner[1].split('::');
var cName:String = tmp.join('.');
return cName;
}
catch( error:Error )
{
}
}
}
return "No caller could be found.";
}
As a side note: this is not set up properly to handle an event model -- sometimes events present themselves as either not having callers or as some very weird alternate syntax.
You don't have to throw an error to get the stack trace.
var myError:Error = new Error();
var theStack:String = myError.getStackTrace();
good reference on the Error class
[EDIT]
Nope after reading my own reference getStackTrace() is only available in debug versions of the flash player.
So it looks like you are stuck with what you are doing now.
Am running asp.net application with access database using gridview application..while running i got the run time error as
Object reference not set to an instance of an object.
Line 41: RadioButtonList rblGender = (RadioButtonList)GridView1.Rows[e.RowIndex].FindControl("rbGenderEdit");
Line 42:DropDownList ddlStatus = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlStatusEdit");
Line 43:SqlDataSource1.UpdateParameters["Sex"].DefaultValue = rblGender.SelectedValue;
Line 44:SqlDataSource1.UpdateParameters["MaritalStauts"].DefaultValue = ddlStatus.SelectedValue;
Line 45: }
I got this error specially in line 43..
So rblGender.SelectedValue or rblGender is null...
Perhaps the problen is with rblGender
Make assignment as follows:
RadioButtonList rblGender = GridView1.Rows[e.RowIndex].FindControl("rbGenderEdit") as RadioButtonList;
And then check for nullability:
if (rblGender == null)
{
//show error
}
RadioButtonList rblGender = (RadioButtonList)GridView1.Rows[e.RowIndex].TemplateControl.FindControl("rbGenderEdit");
if it is in template field.
it can't find rbGenderEdit.
When you have a runtime error like this one, you should use your debugger to actually see what is going on behind the scene. Just put your breakpoint at the line 43 for instance, run your program in debug mode and start investigate to see what object has a null reference and try to fix it.
For instance take a look at the line 41, rblGender might be null...
EDIT
You must check if the objects that you are manipulating are null, this is part of the defensive programming techniques.
In your example, as others have said you can do it this way:
if(rblGender == null) {
// If you are running your program with a console
// Otherwise you should display this anywhere you can or in a log file.
Console.WriteLine("rblGender is null");
}
else if(rblGender.SelectedValue == null) {
Console.WriteLine("rblGender.SelectedValue is null");
}
Run your program and check what is being written! This is not going to solve your problem, but it is just going to tell you where your null reference is which will help you figure out what should be fixed!
But as I said earlier you can also debug your program properly by putting a breakpoint (you know the red ball when you click on the side of the window) at the line 43, and then run your program in debug mode! When the runtime error will fireup you will be able to check whether rblGender or rblGender.SelectedValue is null.
Also, from a more general point of view, checking your object against null references will prevent your application from crashing suddenly by managing the case where an objet might have a null reference at any given time. For instance you can say:
if(my_object is null)
{
myValue = "default";
}
else
{
myValue = my_objet.getValue();
}
This is just an example it could be done in a better way, using exceptions (try/catch/finally) for instance but the general idea is: check against null references!
Have a real puzzler here. I'm using Atalasoft DotImage to allow the user to add some annotations to an image. When I add two annotations of the same type that contain text that have the same name, I get a javascript permission denied error in the Atalasoft's compressed js. The error is accessing the style member of a rule:
In the debugger (Visual Studio 2010 .Net 4.0) I can access
h._rule
but not
h._rule.style
What in javascript would cause permission denied when accessing a membere of an object?
Just wondering if anyone else has encountered this. I see several people using Atalasoft on SO and I even saw a response from someone with Atalasoft. And yes, I'm talking to them, but it never hurts to throw it out to the crowd. This only happens in IE8, not FireFox.
Thanks, Brian
Updates: Yes, using latest version: 9.0.2.43666
By same name (see comment below) I mean, I created default annotations and they are named so they can be added with javascript later.
// create a default annotation
TextData text = new TextData();
text.Name = "DefaultTextAnnotation";
text.Text = "Default Text Annotation:\n double-click to edit";
//text.Font = new AnnotationFont("Arial", 12f);
text.Font = new AnnotationFont(_strAnnotationFontName, _fltAnnotationFontSize);
text.Font.Bold = true;
text.FontBrush = new AnnotationBrush(Color.Black);
text.Fill = new AnnotationBrush(Color.Ivory);
text.Outline = new AnnotationPen(new AnnotationBrush(Color.White), 2);
WebAnnotationViewer1.Annotations.DefaultAnnotations.Add(text);
In javascript:
CreateAnnotation('TextData', 'DefaultTextAnnotation');
function CreateAnnotation(type, name) {
SetAnnotationModified(true);
WebAnnotationViewer1.DeselectAll();
var ann = WebAnnotationViewer1.CreateAnnotation(type, name);
WebThumbnailViewer1.Update();
}
There was a bug in an earlier version that allowed annotations to be saved with the same unique id's. This generally doesn't cause problems for any annotations except for TextAnnotations, since they use the unique id to create a CSS class for the text editor. CSS doesn't like having two or more classes defined by the same name, this is what causes the "Permission denied" error.
You can remove the unique id's from the annotations without it causing problems. I have provided a few code snippets below that demonstrate how this can be done. Calling ResetUniques() after you load the annotation data (on the server side) should make everything run smoothly.
-Dave C. from Atalasoft
protected void ResetUniques()
{
foreach (LayerAnnotation layerAnn in WebAnnotationViewer1.Annotations.Layers)
{
ResetLayer(layerAnn.Data as LayerData);
}
}
protected void ResetLayer(LayerData layer)
{
ResetUniqueID(layer);
foreach (AnnotationData data in layer.Items)
{
LayerData group = data as LayerData;
if (group != null)
{
ResetLayer(data as LayerData);
}
else
{
ResetUniqueID(data);
}
}
}
protected void ResetUniqueID(AnnotationData data)
{
data.SetExtraProperty("_atalaUniqueIndex", null);
}