In a recent project, I needed to round numeric values displayed in the Opportunity Snapshot. This can be done easily using the WebEntityBinding method in the source code file for the Opportunity Snapshot smartpart.
The WebEntityBinding method is contained in the Sage.Platform.WebPortal.Binding namespace, and is used to bind data to controls contained in Saleslogix smartparts. The method contains an overload that allows you to pass a string format during the binding of the control.
For the Opportunity Snapshot, you need to open the OpportunitySnapshot.ascx.cs file under the Portal Manager (Sage SalesLogix – Smartparts – Opportunity). In the OnAddEntityBindings method in that script, you will find the bindings for the controls on the smartpart. To round to the nearest whole number, I just needed to add the format string “{0:0}” as the third parameter passed to the WebEntityBinding call for the appropriate control. Note: If you add the format string parameter, you will also have to pass a “nullvalue” parameter. This is used to return a replacement value if the underlying property returns a null value.
For the Sales Potential value, the following change was made:
Sage.SalesLogix.Security.User user = BindingSource.Bindings.Add(new WebEntityBinding("SalesPotential", curOpenBaseSalesPotential, "Text"));
was changed to:
Sage.SalesLogix.Security.User user = BindingSource.Bindings.Add(new WebEntityBinding("SalesPotential", curOpenBaseSalesPotential, "Text", "{0:0}", null));
That’s all that’s needed! Other format strings could be used for different numeric options as well as date and other string formats.
I hope you found this information useful. Thanks for reading!