Display method refresh issue for the existing lined

I have extended the discpercent() display method in the Sales Line table using COC to calculate the discount dynamically based on the Sales Pool ID. when I select the salespoolid,the display value is showing correct,but if I modify the salespoolid again from the header,the value reflecting for the new lines and not for the existing lines. I had override the modified ds method of salespoolid by calling salesline_ds.executequery()/research () but still no luck.

The whole idea sounds strange to me. Your change of the display won’t change how discounts are calculated, therefore you’ll show users wrong information.

If you want to take sales pools into account when determining prices and discounts, you’ll need to do it in classes like PriceDisc.

Regarding the display method, there is an important concept that you have to learn about: Display methods and Form Observability.

Hi Martin,
Business requirement is to add free of charge based on the salespoolid,so that the discpercent will be 100 else 0. I had override the discpercent method from salesline to include the above logic. As i mentioned it’s giving the result properly when I select for the new lines after changing the salespoolid in the header.But the user may change the salespoolid after creating the lines as well,in that case it should update the discpercent value for the lines created .
[Extensionof (tablestr(salesline))]
public final class test
{
public static discpercent discpct()
{
next discpct();
if(salespool::find(this.salesid).salespoolid).FreeOfCharge)
{
discpct = pricedisc::discpct(100,100,100)
}
return discpct;
,}
Can you guide me on this?

Have you read my reply at all? It seems like you missed both parts.

If you want to real change the discount, your code is wrong. You don’t change what discount is used when calculating the price; you just tell users that the discount is 100%, but it’s not. If extending the display method is a wrong approach, trying to fix the refresh would be a waste of time.

And I also told you what to do with the display method. Please read the blog post I linked; it’ll tell you (among other things) how to tell the system to refresh a display method when something changes in a data source. If you run into a problem, describe the problem, instead of just repeating that the refresh doesn’t work.

Hi Martin,
The link which you shared says it cannot be applied to the table methods.Scenario is,in salespool setup table ,checkbox is placed to define the sales line discount percentage.If it is marked,it show 100 ,else should perform the standard calculation.please help me to achieve this in a better way.

Hi Martin,
Currently the discount percentage (Line percent)field is in Salesline table but the logic is based on the method from Pricedisc class.

The logic of your code is flawed and you should simply stop trying to change this method. If the discount is, say, 5%, it will be 5% even if you return something else from the method. For example, if the item price is 20, the price after the discount will be 19, even if you claim that the discount is 100% or 0%. Which is a logical bug.

I didn’t notice that it’s a table method, but if using z display method was a reasonable approach (which is isn’t), you could create a form display method and put your logic there.