This was the task given and in accordance to the requirement about management of released products I selected the EcoResProductDetailsExtended form and created an extension. I extended the InventTable which is a data source in the form and added custom fields ReviewRating (base enum containing 1-5 rating values) and RatingStar (EDT container) and built the solution after which the fields reflected in the form extension data source and I added ReviewRating to the forms design node and since I can't drag drop a container, I created an image control and bound it to the container by data source and field properties and I also created resources to store images of the star ratings. Created a code extension and wrote this as the code:
[ExtensionOf(formStr(EcoResProductDetailsExtended))]
final class EcoResProductDetailsExtended_YD_Extension
{
public void init()
{
next init();
ProductReview productReview;
FormDataSource inventTableDS = this.datasource(formDataSourceStr(EcoResProductDetailsExtended, InventTable));
if (inventTableDS && inventTableDS.cursor())
{
// Fetch the highest rating for the current product
select firstOnly maxof(ReviewRating) from productReview
where productReview.ProductId == inventTableDS.cursor().(fieldNum(InventTable, ItemId));
if (productReview)
{
str imagePath;
BinData binData = new BinData();
container imageContainer;
// Determine the image path based on the rating
switch (productReview.ReviewRating)
{
case 1:
imagePath = resourceStr("Stars_1");
break;
case 2:
imagePath = resourceStr("Stars_2");
break;
case 3:
imagePath = resourceStr("Stars_3");
break;
case 4:
imagePath = resourceStr("Stars_4");
break;
case 5:
imagePath = resourceStr("Stars_5");
break;
default:
imagePath = resourceStr("NoStarRating");
break;
}
// Load the image into BinData
binData.loadFile(imagePath);
// Convert binary data into a container
imageContainer = binData.getData();
// Update the RatingStar field with the image container
inventTableDS.cursor().(fieldNum(InventTable, RatingStar)) = imageContainer;
// Refresh the data source to display the image
inventTableDS.refresh();
}
}
}
}"
The code isn't showing any errors in the compiler but when I build the solution I get this error:
"SeverityCodeDescriptionProjectFileLineSuppression State
ErrorOperationCanceledException: The operation was canceled.ProductManagement (ISV) [YD]C:\Program Files (x86)\MSBuild\Microsoft\Dynamics\AX\Microsoft.Dynamics.Framework.Tools.BuildTasks.17.0.targets63"
And when I try to separately open the form in F&O it wont let me open it and gives this as an error
"Object reference not set to an instance of an object.
The form with name ecoresproductdetailsextended could not be opened."