Wednesday, 16 August 2017

Display methods in D365 Finance Forms SSRS reports

Display method in Forms
---------------------------------------------------
In AX7 we don’t have the option to create methods on table extension, so we should use the extension class to do that. The example below will show how to create a display method on the table extension class and use on a form extension.
First create your table extension class and your display method following the example below:
1
2
3
4
5
6
7
8
9
public static class MyCustTable_Extension
{
    [SysClientCacheDataMethodAttribute(true)] //This attribute will cache your display method.
    public static display Name myDisplayName(CustTable _this)
    {
        return _this.nameAlias() + "myDisplayName"; //Do here your display method as usual.
    }
 
}
To use your display method on the form, create your new field on the form extension and use the property as below:
Capture
To cache your display method on the form set on the field the property “Cache Data Method” = yes if you don’t want to use the Attribute above.
Capture2

Display method in SSRS reports
------------------------------------------------------

f you are developing report based on query rather on based on RDP, you may want to make use of some display methods, but those may not work. “Not work” means no error in compilation or build, everything great but you may not see any results while you run the report. The returned data can be empty.

If so is the case, I would recommend to create a View and write display methods on the view. Now the display methods which are coming from View, will show you results properly. 


For more details please see below URL's.

https://shyamkannadasan.blogspot.com/2017/07/display-methods-on-ssrs-report-d365o-ax.html

https://community.dynamics.com/365/financeandoperations/b/microsoftdynamicsaxextensions/posts/display-methods-on-ssrs-report-in-msdyn365fo


Tuesday, 15 August 2017

How to disable a form control in AX 365

// <summary>
/// Created by Rahul - 08/15/2017 for disabling LogisticsPostalAddress_Street control
/// </summary>
class LogisticsPostalAddress_EventHandler
{
    /// <summary>
    /// We are disabling LogisticsPostalAddress_Street control here
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(formStr(LogisticsPostalAddress), formMethodStr(LogisticsPostalAddress, updateControls))]
    public static void LogisticsPostalAddress_Post_updateControls(XppPrePostArgs args)
    {
        FormRun sender = Args.getThis();
        sender.control(sender.controlId(formControlStr(LogisticsPostalAddress, LogisticsPostalAddress_Street ))).allowEdit (false);
    }

}

Or second way

[FormControlEventHandler(formControlStr(SalesTable, ButtonLineInventory), FormControlEventType::Clicked)]
    public static void ButtonLineInventory_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormDataSource      salesLine_ds  = sender.formRun().dataSource("salesLine"); //DataSource form CustTable
        FormRun             element       = sender.formRun(); //form element
        FormControl         buttonLineInventReservation   = element.design(0).controlName("buttonLineInventReservation"); //New button on the form

        buttonLineInventReservation.enabled(false);
    }


Please refer below post also.
https://rahulmsdax.blogspot.com/2018/08/how-to-hide-form-control-in-ax-365.html

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...