Showing posts with label FormDataSource. Show all posts
Showing posts with label FormDataSource. Show all posts

Monday, March 6, 2023

How to open multiple Purchase orders in new browser tabs

static public void initFromPurchTable(FormDataSource _formDS)
{
	PurchTable      currentPurchTable;
	Browser         browser = new Browser();
	for (currentPurchTable = _formDS.getFirst(true) ? _formDS.getFirst(true): _formDS.cursor();
	currentPurchTable;
	currentPurchTable= _formDS.getnext())
	{
		var generator     = new Microsoft.Dynamics.AX.Framework.Utilities.UrlHelper.UrlGenerator();
		var currentHost   = new System.Uri(UrlUtility::getUrl());
		generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);
		generator.Company = curext();
		generator.MenuItemName = 'PurchTableListPage';
		generator.Partition = getCurrentPartition();
		// repeat this segment for each datasource to filter
		var requestQueryParameterCollection = generator.RequestQueryParameterCollection;
		requestQueryParameterCollection.AddRequestQueryParameter(
																'PurchTable',
																'PurchId', currentPurchTable.PurchId
																);
		System.Uri fullURI = generator.GenerateFullUrl();
		browser.navigate(fullURI.AbsoluteUri, true);
	}
}

Wednesday, November 20, 2019

Operating with system defined buttons in form Action pane

Say, we have to reference Edit button.



For this we use the macro #define.SystemDefinedViewEditButton('SystemDefinedViewEditButton')

The whole list is present in SysSystemDefinedButtons macro


Code snippet for your active method in name_DS

int active()
        {
            
            #SysSystemDefinedButtons
 
            ret = super();
 
         < ... >
            FormCommandButtonControl editButton = element.control(element.controlId(#SystemDefinedViewEditButton)) as FormCommandButtonControl;
            editButton.enabled(name_ds.allowEdit());
 
            return ret;
        }

Check this article https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/user-interface/system-defined-buttons

Wednesday, April 3, 2019

Accessing FormDataSource

Say, we need to change the form data source sorting order or any other more complex change.

This is an old but good note by Vania Kashperuk about the subject in AX 2012.


public void init()
{
    super();
    this.queryBuildDataSource().addSortField(fieldNum(myDescartesInbound, RecId), SortOrder::Descending);
}