Fetch Parameter name from ID for SSRS Report in D365 Operations

Introduction:

I was stuck in an issue recently where I was working on SSRS report with multiple filter parameters. In multiple parameter, one parameter was Brand ID and in report I had to display the Brand name instead of its ID. In this blog article, we will see how we can get the name of brand as parameter using brand id in Dynamics 365 Operations.

Steps:

  1. Override getFromDialog() Method
  2. getBrandName() method to fetch Brand name.
  3. parmBrandName() to set the value

1. Override getFromDialog() Method: In UI Builder class override getFromDialog() method. This method gets the value of Brand Id.

/// <summary>
 /// Transfers data from the dialog into the data contract object.
 /// </summary>
 public void getFromDialog()
 {
 super();
 RecId r;
 r = contract.parmEcoResCategoryId();
 if (r) 
 contract.parmBrandName(this.getBrandName(r));
 }

2. getBrandName() method to fetch Brand name: This method is used to find Brand name and called from getFromDialog() method. The return value is passed as parameter to contract class.

 /// <summary>
 /// This method looks up name of the organization using the hierarchy relationship id.
 /// </summary>
 /// <param name = "hierarchyRelationshipId">The hierarchy relationship id for the organization.</param>
 /// <returns>Name of the organization.</returns>
 public EcoResCategoryName getBrandName(RecId hierarchyRelationshipId)
{
   EcoResCategory category;

  select firstonly Name from category 
   where Category.RecId == hierarchyRelationshipId;

  return category.Name;
}

3. parmBrandName() to set the value: This method gets or sets the value of Category Name.

/// <summary>
 /// Gets or sets the value of the datacontract parameter Category Name.
 /// </summary>
 /// <param name="_categoryName">
 /// The new value of the datacontract parameter CategoryName; optional.
 /// </param>
 /// <returns>
 /// The current value of datacontract parameter CategoryName
 /// </returns>
 [
 DataMemberAttribute('Retail Category Name'),
 SysOperationLabelAttribute(literalstr("Brands")),
 SysOperationHelpTextAttribute(literalstr("Brands Category"))
 ]
 public EcoResCategoryName parmBrandName(EcoResCategoryName _categoryName = categoryName)
 {
 categoryName = _categoryName;
 return categoryName;
 }

Conclusion:

This blog showed how we can fetch the parameter value from another parameter in SSRS report using filter parameters with Contract and UIBuilder class in D365 Operations.


Share Story :