Thursday, July 6, 2023

Add Bar Code in SSRS report

1)     Set text box font  property to ”BC C39 2 to 1 Medium”

 



2) set expression of textBox as “"*" & First(Fields!HeatNumber.Value, "DS") & "*"”




Add range on Enum type field , d365 , x++

 We can add range on enum type field like this 

public void executeQuery()
{
    this.query().dataSourceTable(tableNum(CMSProspectStudentAssessmentTable)).addRange(fieldNum(CMSProspectStudentAssessmentTable , AssessmentStatus)).value(queryValue(CMSAssessmentStatus::AssessmentScheduled));
    super();
}








Lock or hide range on a form , D365 , X++

To Lock r hide range on the form we have Status method of QueryBuildRange


 public void executeQuery()
  {
        QueryBuildDataSource qbds;
        QueryBuildRange         qbr;
        qbds = this.query().dataSourceTable(tableNum(CMSProspectParentTable));
        qbr = qbds .addRange(fieldNum(CMSProspectParentTable , ParentId));
        qbr.value("anyParentId");			//two dots are considers as empty string in ax
        
        //qbr.status(0);
        //qbr.status(1);
        qbr.status(2);
   }  

qbr.status() method takes an integer parameter 

The following values are possible for the status:

ValueStaus
0Status Open.
1Status Lock.
2Status Hide.


Ref Link: https://learn.microsoft.com/en-us/dotnet/api/dynamics.ax.application.querybuildrange.status-

Add range of null (empty) string , d365 , x++

 Use following code to add range of empty or null string in any of the table , datasource field

  public void executeQuery()
  {
        QueryBuildDataSource qbds;
        QueryBuildRange         qbr;
        qbds = this.query().dataSourceTable(tableNum(CMSProspectParentTable));
        qbr = qbds .addRange(fieldNum(CMSProspectParentTable , ParentId));
        qbr.value("..");			//two dots are considers as empty string in ax
  }
Two dots are considered as empty string in ax

qbr.value("..");

Add date range with date less than current date (filter records with date less than or equal to today date) d365 , x++

 Create COC of form's data source and add this code in ExecuteQuery method that datasource


[ExtensionOf(formDataSourceStr(SalesTable , SalesLine))]
final class KA_SalesLineDS_Extension
{
    public void executeQuery()
    {
	this.query().dataSourceTable(tableNum(SalesLine)).addRange(fieldNum(SalesLine , InvoiceGenerationDate)).value(SysQuery::value(dateNull() + 1) + ' .. ' +  SysQuery::value(today()));
    }
}
SysQuery::value(dateNull() + 1) + ' .. ' +  SysQuery::value(currentDateTime)

This is the range of date less than or equal to Today date.

Add Range In Default Dimension , D365 , X++

 I am going to show you How You can add range in any default dimension .

If it it standard form where you want to add range then you have to create COC of that form's dataSource which contains DefaultDimension Field. 

In my example I am adding range in Default Dimension "Project" in  Revenue Recognition Schedule(RevRecDefferredLine) Form  . I want to show just that particular record whose projectId matches the string control named "ProjIdFilter" whice I added in my form through form extension


Create the COC of RecRecDefferredLine form's datasource "NetDefferredLine" beacase my default dimension field is in NetDefferredLine datasource and paste below code


[ExtensionOf(formDataSourceStr(RevRecDeferredLine , NetDeferredLine))]
final class MZNKARevRecDeferredLineDS_Extension
{
    public void executeQuery()
    {

        FormRun                 fr = this.formRun();
        FormStringControl       projectIdFilter = fr.design(0).controlName(formControlStr(RevRecDeferredLine , ProjIdFilter));
        DimensionProvider       dimensionProvider = new DimensionProvider();
		
        dimensionProvider.clearDimensionRangesFromQuery(
				this.query());


        dimensionProvider.addAttributeRangeToQuery(
				this.query(),
				this.name(),
				fieldStr(RevRecDeferredLine, DefaultDimension),
				DimensionComponent::DimensionAttribute,
				ProjectIdFilter.valueStr(),
				"D05_ActivityName");
 
 
        next executeQuery();
    }
}


Explanation:
What this code does is to set the range of default dimension named "Project" with the filter string which I added in form

DimensionProvider dimensionProvider = new DimensionProvider();

It will call the constructor of class DimensionProvider


 dimensionProvider.clearDimensionRangesFromQuery(
				this.query());
This line will clear the already applied ranges

 dimensionProvider.addAttributeRangeToQuery(
				this.query(),
				this.name(),
				fieldStr(RevRecDeferredLine, DefaultDimension),
				DimensionComponent::DimensionAttribute,
				ProjectIdFilter.valueStr(),
				"Project");
This code does the actual work 
First argument is the Query name 
Second argument is the datasource name of which you are adding range
3rd argument is the default dimension field 
4th argument is to specify that it is default dimension
5th argument is the string which you want to filter 
6th argument is the that specific default dimension name I my case I am applying range in "Project" dimension

Change SSRS Report Design Based On Condition , D365 ,X++

 To change Sales Invoice control document's design based on condition use following code. Here I have created COC of salesInvoiceControl...