Accessing Axapta report fields - axapta

I want to iterate over the fields of an Axapta report.
The problem I am facing is that I want to turn the fields visible and invisible before the report is shown. So I am overriding the Display method and add checkboxes to the Dialog.
I am looking for something that I can iterate over, like this
pseudocode:
public Object dialog(Object _dialog)
{
ListIterator it;
Dialog dialog;
;
it = new ListIterator (this.fields);
dialog = super(_dialog);
while (it.more())
{
dialog.addField(typeId(NoYesId),it.value);
it.next();
}
return dialog;
}
How can I access the fields of a report ?
Further information:
I am using Dynamics Ax 4.0

First, take a look on this question.
To access a report field, set the fields AutoDeclaration to Yes. Then the field is open for whatever:
stringControl.visible(...);
See report tutorial_FontInfo for an example of locating the control by name.
All controls of a report section can be accessed by number:
for (i = 1; i <= reportSection.controlCount); i++)
{
rc = reportSection.controlNo(i);
}

Related

Devexpress XAF (Blazor) Popup window to edit property

I have an XAF application. Most of my Business Objects are based on a baseclass "MyBaseClass" which contains Createdby, ModifiedBy, ... Comments. The Comments field is AllowEdit=false. I only want users to be able to modify the comment thru an action which would allow them to create an entry to which I would prepend their UserName and timestamp.
I don't know how to pop up a window to edit a property (string) within the current object and view.
There are plenty of examples of how to CreateListView but in this case what I wish to edit in the popup is not a separate BO but just a string. Maybe that is my problem(???)
I have the Action Controller and I am not sure how to create the DetailView when I get into the _Execute()
In Winforms XAF I add an action in a view controller.
In the action's execute event I call something like
private void actOpenDetailView_Execute(object sender, SimpleActionExecuteEventArgs e)
{
var application = Controller.Application
var viewId = application.FindDetailViewId(typeof(MyBusinessObject));
application.CreateObjectSpace(typeof(MyBusinessObject));
var detailView = application.CreateDetailView(newObjectSpace, jh, true);
e.ShowViewParameters.CreatedView = detailView;
e.ShowViewParameters.TargetWindow = TargetWindow.NewWindow;
}
I haven't tried that in Blazor.

How do I create something that works like a logging control in Xamarin.Forms

I'm after something like the application output window in Visual Studio, like so:
I'd like to be able to:
bind to an ObservableCollection of strings
select and copy text (as shown in the screenshot above)
At present this is for a Mac app, although iOS may follow later.
I've tried these:
Editor - Problem is it only exposes a Text property that I can bind to and not a collection. Sooner or later, the maximum string length will be reached.
ListView with Label for ViewCell - Problem is text from a Label is not selectable, let alone having multiple lines (bound collection items) selectable.
Using a custom renderer for Mac that makes use of NSTextView and appending to textStorage every time a new item is added, but again, there’s a limit to how much you can add to textStorage.
I'm open to using third-party tools such as Syncfusion, if that makes it easier.
Custom a method to deal with list data to combine them into a newline string :
public string formatstring(NSArray objects)
{
StringBuilder stringBuilder = new StringBuilder();
for(nuint i=0;i< objects.Count; i++)
{
stringBuilder.Append(objects.GetItem<NSString>(i) +"\n");
}
return stringBuilder.ToString();
}
Then used in NSTextView as follow :
string[] items = new string[] {"111111" , "222222" , "333333" , "444444" , "555555" };
NSArray array = NSArray.FromStrings(items);
NSTextView textView = new NSTextView(new CGRect(100,160,200,100));
textView.BackgroundColor = NSColor.Gray;
textView.Value = formatstring(array);
View.AddSubview(textView);
The effect :

2sxc Prefill datetime value in Manage Content Data

I created a Entity in Content-Types and Data and this entity have a field that is a datetime
When I click in the Plus button (+) I want to hide the field from user (this I got) and that default value be the current date (to be filled behind the scene)
Is there a way to achieve this ?
I read about prefill but I dont got how to do that with the default "Manage Content / Data"
I´m using 2sxc 10.24.0
Welcome to StackOverflow, #Alexandre ;)
The special buttons can only be done in the view. The internal manage-data doesn't provide options to customize. You can set default texts, but there is currently no mechanism to provide tokens, JS or something to get dynamic values as an initial value from the normal Admin-dialogs.
I got if I create a view and then use
#Edit.Toolbar(toolbar: new object[] { new { command = new { action = "new", contentType = "Articles", prefill = new { CreationDate = DateTime.Now } }}}
I believe that to do that in Manage Content / Data will be need to modify the "view" from the 2sxc

How to refresh Factbox

I have a form, when i click on my button.It adds to my table A (what my factbox shows)is it possible to refresh the factbox with X++ code? I can't figure out how to refresh my infopart or query which factbox uses.
For an infopart you can call an update of the data source of the infopart's form run:
void clicked()
{
PartList partList;
int i;
FormRun infoPartFormRun;
FormDataSource infoPartDataSource;
super();
partList = new PartList(element);
for (i = 1; i <= partList.partCount(); i++)
{
infoPartFormRun = partList.getPartById(i);
if (infoPartFormRun.name() == identifierStr(MyInfoPart))
{
infoPartDataSource = infoPartFormRun.dataSource();
if (infoPartDataSource)
{
infoPartDataSource.research();
}
}
}
}
I added the check for the infoPartDataSource because I first tested this with a cue group fact box, which does not have a data source (or at least I could not figure out how to get the data source of one of the cues in the cue group and since you asked for an infopart fact box, I did not investigate further).
Update: The issue seems to be popular at the moment, Martin Dráb also wrote in his blog about it: Refreshing form parts

how to set autosum property in x++ for a morphx report

I have the following code in the init() of a report:
QueryBuildDataSource qbdsTable;
QueryOrderByField QueryOrderByFieldTransDate;
QueryOrderByField QueryOrderByFieldDimZone
QueryOrderByField QueryOrderByFieldDimCC;
;
super();
qbdsTable = query.dataSourceTable(tableNum(Table));
QueryOrderByFieldTransDate = qbdsTable.addOrderByField(fieldNum(Table, TransDate));
QueryOrderByFieldTransDate.autoSum(true);
QueryOrderByFieldDimZone = qbdsTable.addOrderByField(fieldNum(Table, DimZone),SortOrder::Descending);
QueryOrderByFieldDimZone.autoSum(true);
QueryOrderByFieldDimCC = qbdsTable.addOrderByField(fieldNum(Table, DimCostCenter));
QueryOrderByFieldDimCC.autoSum(true);
and the autosum property is functioning properly (I have set the SumAll property for the field I use to calculate these subtotals).
The problem is that, whenever I try to add an groupBy field or a selection field, the autosum property isn't honored anymore (the subtotals are not displayed anymore):
qbdsTable.addSelectionField(fieldNum(Table, AmountMST), selectionField::Sum);
or
qbdsTable.addGroupByField(fieldNum(Table, TransDate));
I have tried to use:
qbdsTable.addSortField(fieldNum(Table, TransDate));
qbdsTable.autoHeader(1, true);
but I have the same problem
Does anyone has an Idea how I can use both autosum and addGroupByField on the same datasorce of a report?
For historical reasons old style AX reports behaves differently when called directly (run on the report node) or through on a report menu item.
The execution order of the first is:
init
fetch
dialog
The second runs via class RunbaseReportStd in the following order:
init
dialog
fetch
This matters because you have change the query after the user has made any changes.
So move your code changes from init to fetch, like this:
public boolean fetch()
{
QueryBuildDataSource qbdsCustTrans = query.dataSourceTable(tableNum(CustTrans));
;
qbdsCustTrans.addSelectionField(fieldNum(CustTrans, AmountMST), selectionField::Sum);
qbdsCustTrans.addGroupByField(fieldNum(CustTrans, AccountNum));
qbdsCustTrans.addGroupByField(fieldNum(CustTrans, TransDate));
qbdsCustTrans.addGroupByField(fieldNum(CustTrans, CurrencyCode));
//info(qbdsCustTrans.toString());
return super();
}
This will only work, if called through the menu item.
Also, I could not get the auto-sum functionality to work, when added by code.
Instead you will have to add the order by and autosum using Sorting node of the report query.
I don't know why, but maybe this is because you use auto design, which is generated at run time.

Resources