June 09, 2023

How to add security on a specific control on form

Hi Folks, 

In this post, I will discuss how to enhance security for a specific form control, such as a button or checkbox. Typically, we would use the DisplayMenuItem feature to manage security privileges. However, things can become a bit different when you want to assign special security privileges to a particular form control.

Here's a standard approach to achieving this. Please follow the steps below:

1.              Begin by navigating to the form design and selecting the desired form control to which you want to add additional security privileges.

a.     Set the property 'Need permission' to 'Yes'. This step will make the field available in Step 5.

2.         Create a new privilege. If an existing one suits your requirements, feel free to use it.

3.         Within the privilege settings, locate the 'Form control permission' section.

4.         Add a new form here.

5.         Include the control on this form and adjust its properties accordingly.

By following these steps, you can implement enhanced security measures for specific form controls.






-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta

June 06, 2023

Simplifying Data Retrieval with D365FO X++ Lookup Method

Simplifying Data Retrieval with D365FO X++ Lookup Method

Simplifying Data Retrieval with D365FO X++ Lookup Method

Introduction

Microsoft Dynamics 365 for Finance and Operations (D365FO) is a powerful ERP system that offers robust customization capabilities. One such customization option is the ability to write X++ code for lookup methods. These methods can greatly simplify data retrieval and enhance the user experience within the application. In this blog post, we will explore the lookup method in D365FO X++ code and provide a sample code snippet to demonstrate its usage.

Understanding the Lookup Method

The lookup method in D365FO X++ code allows developers to retrieve data from related tables or data sources based on specified criteria. It enables users to select a value from a predefined set of options, providing a seamless way to populate fields with accurate and relevant information. The lookup method essentially acts as a search functionality within the application, making it easier for users to find and select the desired data.

Sample Code

    
public static void lookupDemo(FormStringControl _control)
{
    SysTableLookup        sysTableLookup;
    QueryBuildDataSource  queryBuildDataSource;
    QueryBuildRange       queryBuildRange;

    sysTableLookup = SysTableLookup::newParameters(tablenum(CustTable), _control);
    queryBuildDataSource = sysTableLookup.addDataSource(tablenum(CustTable));

    // Adding a range to filter the lookup results
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, AccountNum));
    queryBuildRange.value("1001");  // Setting the filter value

    sysTableLookup.performFormLookup();  // Opening the lookup form
}
    
  

Explanation

In the above code, we start by creating a new instance of the SysTableLookup class, passing the target table and the control where the lookup will be displayed as parameters. In this case, we use the CustTable table and the _control argument, which represents the form string control.

Next, we add a data source to the lookup using the addDataSource() method. Here, we specify the table we want to retrieve data from (in this case, CustTable).

To filter the lookup results, we add a range using the addRange() method on the queryBuildDataSource. In this example, we filter the results based on the AccountNum field and set the filter value to "1001".

Finally, we call the performFormLookup() method on the sysTableLookup object, which opens the lookup form for the user to select the desired value.

Conclusion

The lookup method in D365FO X++ code provides a convenient way to retrieve and display data from related tables or data sources. By implementing lookup functionality, developers can enhance the user experience by simplifying data selection and ensuring the accuracy of entered values. The code snippet provided above serves as a starting point for utilizing lookup methods in your D365FO customization projects. Experiment with different tables, filters, and fields to tailor the lookup functionality to meet your specific business requirements.

-Harry Follow us on Facebook to keep in rhythm with us. https:fb.com/theaxapta