Call child form programmatically with parameter / filter - axapta

I'm creating a customization where on a click of a button, I need to allocate a charge for a particular purchase order / invoice journal.
From the front end, I would accomplish this by following the purchase order life-cycle and invoicing it. I would then go under the invoice tab of the PO, click Invoice Journals -> Charges -> Adjustment . This will open up my desired form where I will select a charges code, charges value, currency and category, and then I will click 'Ok' and have the system take care of the rest of the process.
Form name: MarkupAllocation_VendInvoiceTrans
Parent form Name: VendInvoiceJournal
You can see that the child form gets called with a few parameters such as the invoice number, there obviously needs to be that link. If I go into the AOT under forms, I right click and open up VendInvoiceJournal, but I wouldn't be able to open up MarkupAllocation_VendInvoiceTrans because it requires parameters.
Objective:
A: To open MarkupAllocation_VendInvoiceTrans through code where I manually pass those parameters to link to the parent table. I would provide the invoice number and such. The objective is to skip opening the parent table and manually going into the adjustments. I want to open that form directly and have it link to whichever record I specify.
B: I need to be able to pass a _ChargesValue parameter and have that be pre-populated for me. I don't know if this is possible, so I wanted to ask and confer. Ideally, I should be able to click a button on my custom form, and have MarkupAllocation_VendInvoiceTrans form directly open for a specified invoice, with pre-populated values on the line.
I know I should be tackling this problem one step at a time, so step A is priority number one.
I can open up the parent form with relative ease like so, but I cannot do the same for the child form. Obviously the same time of approach won't work, as I need to specify the relationship of the parent table before I open it.
private void allocateMarkup()
{
Object formRun;
Args args = new Args();
VendInvoiceJour jourTable;
;
select * from jourTable where jourTable.PurchId == 'PO000001191';
args.name(formstr(VendInvoiceJournal));
args.record(jourTable);
formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}
How would I be able to do so?
(Side note, I realize this whole form calling could be avoided if do all the transactions programmatically instead of letting the out of the box functionality handle it, but the markup and allocation logic is a beast of it's own and to me seems much more complicated than doing this. If someone has done it this manual way, any help on that would be greatly appreciated as well)

If I read your post right, you just want to open the Charges>Adjustment for a certain invoice. Here is one simple method:
MarkupAdjustment markupAdjustment = new MarkupAdjustment();
markupAdjustment.vendInvoiceJour(VendInvoiceJour::findFromPurchId('PO 120079'));
markupAdjustment.run();

Related

fragment vs activity onClickButton functions - where is right place

I made an andorid application using the "activity" component. I used it for a while, but over time I found that one page was not enough for me. I needed to add tabLayout, viewPager2 and three fragments.
I needed to migrate the functionality from mainActivity to the firstFragment.
I encountered a problem with events during the XML migration. In the activity I called android: onClick = "myOnClicFunction". But is that not possible?
I know that this has been discussed several times here in several threads. However, I would like to ask how to proceed correctly.
Here in the thread Android Fragment onClick button Method is the advice "even if you are in the fragment, put the onClick functions into activity" there is another similar advice to, "if you insist to make it in a fragment"
But what is right? Should the onclick function be correct in the activity or in the fragment?
I don't want to put the source code here, because I don't know which procedure is correct at all.
I am creating a program that is for testing students. An example is displayed and a response is pending.
The first tab has a lot of buttons + saves the result to an xml files.
The second tab will contain statistics. From saved files displays how many calculations were correct, wrong, average response time, etc ...
In Activity I had functions like getQuestion(), evaluateQuestion(), saveToXml() and events zeroWasPressed(), oneWasPressed(), twoWasPressed(), threeWasPressed() ...
Where should I put all these functions when I change the application from Activity to Fragment?
on click function listener should be placed in corresponding fragment, where the button is added in fragment layout.
events zeroWasPressed(), oneWasPressed(), twoWasPressed(), threeWasPressed() ... should be placed inside corresponding fragment where those buttons were added in layout.
getQuestion(), evaluateQuestion(), saveToXml() , this function can be placed in your activity or some other custom classes, that would appropriate according to architecture viewpoint.

QT Creator: Trigger a Slot with Code?

I may have worked myself into a corner but this sounded to me like a good idea at the time.
I have been developing an interface that permits a user to modify settings of a robotic device, i.e. speed, directions, force, etc. with a very large series of options in the form of ComboBoxes. The problem is that there are about a thousand of these things, in sub categories. e.g. Speed category x1, x2, x3, Y1, y2, etc. So rather than create a thousand comboboxes in QT, I thought the good idea was to create one set of 50 (ish) and then provide a few button to switch between categories. So when the user selects speed QT, populates the comboboxes with the appropriate options, sets the style sheets and text for the labels etc. So it appears as though a dedicated page exists. Then if the user selects Direction, QT Writes the current index of each box to a dedicated array and then repopulates the boxes, labels etc with the appropriate content. I then do this over and over for the various needs of the system.
All of that seems to work fine. However I am now in a bind where the options provided to navigate to each page have grown. For instance I have forward / backward buttons (like you woudl expect in a set-up wizard), as well as action menus at the top to jump to a page. So now the code is becoming very repetitious. If you select the next button, I write the current values to array, then repopulate. If you jump to the page from anywhere, I look to see where I am, write it to array, and populate the boxes. Thus if I need to change anything I have to make the change in numerous places in the code.
I know that this is not optimal. What I woudl like to do is run a continuous loop as I woudl normally do with Micros in C. So the program can look at a variable in each pass and if it is then it does. I am not however skilled enough to figure this loop out in QT. So my new thought was...
Is it possible to trigger an action or slot with a variable. For example, if the user presses the Next button it triggers a slot for a button that does not exist, so that QT will execute a particular line of Code? Then I can have 1 dedicated section focused on reading and writing boxes, with a bunch of actions that will take me there.
You can make a signal that is triggered with an emit call in your code, so you'd hook up the next button signal of clicked to a slot that does some work and moves on, or directly calls another signal that you've created that triggers a slot elsewhere, or do some work in a lambda triggered by the button press.
I would first load all the ComboBoxes options in a QStringList array (or maybe an array of QList<QLatin1String> lists - for memory saving and code efficiency).
Then I would keep an array of a 1000 integers for current ComboBox indexes.
When the user changes a value in some ComboBox, the currentIndexChanged signal will trigger the corresponding slot (a single slot for all the ComboBoxes would be enough - sender()->objectName() to get the name of the ComboBox which had sent the signal):
void WindowWidget::on_ComboBox_currentIndexChanged(int index)
{
name = sender()->objectName();
/* here change the corresponding integer in the current
indexes array */
}
On Next/Back button push repopulate the ComboBoxes. Also, provide some 'Save' button for saving the ComboBoxes indexes (or trigger the Save slot on some action, i.e. on window close either even on a timer signal).

Lightswitch HTML databinding to a details collection

I have a simple master/details relationship where one order can have multiple revenue allocations. The order has a collection that contains these.
I want to sum a property in my revenue allocation objects and ensure that it adds up to my order total. However, if I databind on the count property of the allocations collection this gets called when you first add an empty object and not when that object has been populated. So an empty allocation is added at the time the "Add allocation" screen is created and the databind function called. That of course means that when the save button on the "Add allocation" screen is clicked, the databind function isn't called again.
Anyone got any ideas? I basically want my databind function to be called when the save button is clicked in the "add screen" and not before.
This is the HTML client - NOT Silverlight
I'm pretty sure that the solution would be to use an OData query to get your aggregate data within the databinding function of the save button - or perhaps a separate button (e.g. "Tally Order Totals"). Exactly how you do that? A bit too hard for me to answer right now, but start with a new button TallyOrderTotals and a new data field for your total. Edit the post_render event for TallyOrderTotals and lookup the allocations in the javascript in which you data bind the value of the new data field.
Somewhere you will need a piece of code that looks something like this:
myapp.activeDataWorkSpace.<datasource>.RevenueAllocations
.filter("OrderID eq " + msls._toODataString(<orderID>, ":String"))
.execute()
.then(function (result) {
// assign the result somewhere
}
I'm not saying that's something you can cut-and-paste - but definitely look at the msls.js documentation and see what you can do with querying your data inside the event context.
One quick point however - if you only need to calculate that total as a verification step, consider doing it in the SaveExecuting() event on the server side. This will allow you to throw an exception back up the tree to your HTML page which the msls.js script should render on the client side.
Hope that helps. :)

copy/paste of Page doesn't start workflow in same SG, starts workflow in other SG

I was perplexed by a user turning up this sort of behavior recently. Assume all SGs have workflow set.
Copy Page X in SG A, paste in same SG A. Page Y is created but no workflow is initiated.
Copy Page X in SG A, paste in other SG B. Page Z is created and workflow is initiated.
Now, the first scenario I confirmed with Nuno when he was on site. We agreed with business folks that we can live with that behavior. However, I'm curious why the second scenario happens as-is. If #1 doesn't kick off workflow, why should #2? Can anyone explain why? Is there any way I could programmatically cause scenario #1 to start the workflow (as the business would like that to happen)? or, worst case disable it from #2. It should be consistent.
But in practical scenario, I would really question the need for workflow to kick off as soon as you copy the page in the same structure group.
When you copy a page in the same structure group, it will create a page with title Copy of original page name and the CMS User will obviously wants/needs to edit the page with proper page name. As soon as they save the page workflow kicks in. Also, CMS user may want to change some component presentations on the page as well.
When you copy this on a different structure group, you are creating a page with a name in other structure group, so the workflow kicks in since it is not same copy in same structure group.
I would consider this as a nice feature :) :).
However as Nick suggested I would recommend submitting a support ticket as well.
If you want to consider a programmatic approach for your scenario # 1, you could implement the EventSystem to force the workflow kick off by simply saving the page again with same user who created it. You need to capture the CopyEvent .
Sample EventSystem stub if you want to go this route (Not Tested) :
private void Subscribe()
{
EventSystem.Subscribe<Page, CopyEventArgs>(PostCopyActivity, EventPhases.Processed);
}
private static void PostCopyActivity(Page page, CopyEventArgs args, EventPhases phase)
{
// do your logic to save page..
string sourceId = args.CopiedObject.OrganizationalItem.Id;
string destinationId = args.Destination.ToString();
if (sourceId.Equals(destinationId))
{
// copying to the same location .. so now get the User Session and Update the page to force workflow
}
}
Hope this information helps.
I went ahead and tried this on my system, and it does not start a workflow in any case (copy/pasting to same structure group or different structure group).
Do you have an event triggered on Paste?

Displaying TableView when MKAnnotation(Pin) in MKMapView touched/pressed/clicked

I want to display quite a bit of demographic data for a certain pin when someone touches on it, so providing a pop-up isn't going to cut it. I figured once the pin is touched I will just stick a tableviewController onto the NavigationController and the table view will have access to the object and display the single objects information, with one item per row and 1 section.
Anyway I'm having a hard time figuring out MKMapViewDelegates methods as it appears none of them do what I need and/or allow me to return a tableview or push that view onto the navigation controller.
I played around with:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation;
But that requires a MKAnnotationView be returned and I really just need this method to work by showing the user a table view of all the data. I was hoping for something simple like a userDidTouchPin method....
Anyone have any ideas how to accomplish what I am trying to do?
If you want to do something when the user selects the pin (and not a button on its callout), then implement the mapView:didSelectAnnotationView: delegate method and present or push your detail view controller there.
The selected annotation object is available as the annotation property of the view parameter:
- (void)mapView:(MKMapView *)mapView
didSelectAnnotationView:(MKAnnotationView *)view
{
YourDetailViewController *dvc = [[YourDetailViewController alloc] init...
dvc.annotation = view.annotation;
//present or push here
[dvc release];
}
You might need to check which type of annotation was selected (eg. if MKUserLocation was selected do nothing, etc) and you might need to cast the view.annotation to your own annotation class to easily access any custom properties you may have.

Resources